Stripe-android: (NoSuchFieldError) crash when trying to add new card from PaymentMethodsActivity

Created on 1 Oct 2017  路  2Comments  路  Source: stripe/stripe-android

I setup the sdk fine, and then made this class to generate empirical key with my server..!
and the it gives response normally.

public class CustomEphemeralKeyProvider implements EphemeralKeyProvider {

  @Override
  public void createEphemeralKey(@NonNull @Size(min = 4) String apiVersion,
      @NonNull final EphemeralKeyUpdateListener keyUpdateListener) {
    AndroidNetworking
        .post("https://****key.herokuapp.com/ephemeral_keys?api_version=2017-0****")
        .setTag("test")
        .setPriority(Priority.HIGH)
        .addPathParameter("customer", "cus_BUjgC0********")
        .build()
        .getAsJSONObject(new JSONObjectRequestListener() {
          @Override
          public void onResponse(JSONObject response) {
            keyUpdateListener.onKeyUpdate(response.toString());
          }
          @Override
          public void onError(ANError anError) {
            anError.printStackTrace();
          }
        });
      }}

Then once the user press pay. PaymentMethodsActivity shows no problem, but with no cards.. If I click on (Add New Card..) it crashes and gives me NoSuchFieldErrorexception??

The Code:

     PayButton.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View view) {
         CustomerSession.initCustomerSession(new CustomEphemeralKeyProvider());
         Intent payIntent = PaymentMethodsActivity.newIntent(PaymentProcess.this);
         startActivityForResult(payIntent, REQUEST_CODE_SELECT_SOURCE);
        }
      });


       //  code....


    @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
       if (requestCode == REQUEST_CODE_SELECT_SOURCE && resultCode == RESULT_OK) {
       try {
         String selectedSource = data.getStringExtra(PaymentMethodsActivity.EXTRA_SELECTED_PAYMENT);
         Source source = Source.fromString(selectedSource);
           } catch(Exception ex){
        ex.printStackTrace();
          }
        }
      }

The Error

   AndroidRuntime: FATAL EXCEPTION: main
  Process: com.****.****, PID: 10164
    java.lang.NoSuchFieldError: No static field progress_bar_as of type I in class Lcom/stripe/android/R$id; 
       or its superclasses (declaration of 'com.stripe.android.R$id' appears in 
      /data/app/com.*****.*******-1/split_lib_slice_1_apk.apk)
   at com.stripe.android.view.StripeActivity.onCreate(StripeActivity.java:42)
   at com.stripe.android.view.AddSourceActivity.onCreate(AddSourceActivity.java:65)
   at android.app.Activity.performCreate(Activity.java:6248)
   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
   at android.app.ActivityThread.access$900(ActivityThread.java:150)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:168)
   at android.app.ActivityThread.main(ActivityThread.java:5845)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)

Most helpful comment

Nevermind, the error showed because I created an activity before which has a layout file with a name identical to another layout file of the Stipe SDK. so Stripe didn't find the views IDs in my xml layout file and throws an exception instead.

Once I renamed my xml layout file, the problem is solved.

All 2 comments

Nevermind, the error showed because I created an activity before which has a layout file with a name identical to another layout file of the Stipe SDK. so Stripe didn't find the views IDs in my xml layout file and throws an exception instead.

Once I renamed my xml layout file, the problem is solved.

thank you so much

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jose-t picture jose-t  路  8Comments

andrewmunn picture andrewmunn  路  4Comments

mckn picture mckn  路  9Comments

HanteIsHante picture HanteIsHante  路  9Comments

GuillaumeWrobel picture GuillaumeWrobel  路  8Comments