In-App Payments: Error ('Failed resolution of: Lcom/squareup/Card$Brand;') when calling StartCardEntryActivity

I’m using the in-app payments sdk and I’m having an issue when I try to start the card entry activity. I get the following error:

Java.Lang.NoClassDefFoundError: ‘Failed resolution of: Lcom/squareup/Card$Brand;’

12-16 15:03:36.213 I/MonoDroid(12441): UNHANDLED EXCEPTION:
12-16 15:03:36.221 I/MonoDroid(12441): Java.Lang.NoClassDefFoundError: Failed resolution of: Lcom/squareup/Card$Brand; —> Java.Lang.ClassNotFoundException: Didn’t find class “com.squareup.Card$Brand” on path: DexPathList[[zip file “/data/app/com.tekwavesolutions.host-1/base.apk”],nativeLibraryDirectories=[/data/app/com.tekwavesolutions.host-1/lib/arm64, /data/app/com.tekwavesolutions.host-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
12-16 15:03:36.221 I/MonoDroid(12441): — End of inner exception stack trace —
12-16 15:03:36.221 I/MonoDroid(12441): — End of managed Java.Lang.NoClassDefFoundError stack trace —
12-16 15:03:36.221 I/MonoDroid(12441): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/squareup/Card$Brand;
12-16 15:03:36.221 I/MonoDroid(12441): at sqip.internal.CardEditorState.(CardEditorState.kt:23)
12-16 15:03:36.221 I/MonoDroid(12441): at sqip.internal.CardEntryActivity.onCreate(CardEntryActivity.kt:116)
12-16 15:03:36.221 I/MonoDroid(12441): at android.app.Activity.performCreate(Activity.java:6942)
12-16 15:03:36.221 I/MonoDroid(12441): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
12-16 15:03:36.221 I/MonoDroid(12441): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2880)
12-16 15:03:36.221 I/MonoDroid(12441): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)
12-16 15:03:36.221 I/MonoDroid(12441): at android.app.ActivityThread.-wrap14(ActivityThread.java)
12-16 15:03:36.221 I/MonoDroid(12441): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)
12-16 15:03:36.221 I/MonoDroid(12441): at android.os.Handler.dispatchMessage(Handler.java:102)
12-16 15:03:36.221 I/MonoDroid(12441): at android.os.Looper.loop(Looper.java:154)
12-16 15:03:36.221 I/MonoDroid(12441): at android.app.ActivityThread.main(ActivityThread.java:6682)
12-16 15:03:36.221 I/MonoDroid(12441): at java.lang.reflect.Method.invoke(Native Method)
12-16 15:03:36.221 I/MonoDroid(12441): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
12-16 15:03:36.221 I/MonoDroid(12441): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
12-16 15:03:36.221 I/MonoDroid(12441): Caused by: java.lang.ClassNotFoundException: Didn’t find class “com.squareup.Card$Brand” on path: DexPathList[[zip file “/data/app/com.tekwavesolutions.host-1/base.apk”],nativeLibraryDirectories=[/data/app/com.tekwavesolutions.host-1/lib/arm64, /data/app/com.tekwavesolutions.host-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
12-16 15:03:36.221 I/MonoDroid(12441): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
12-16 15:03:36.221 I/MonoDroid(12441): at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
12-16 15:03:36.221 I/MonoDroid(12441): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)

I looked in the CardEditorState class and found that it does an import of com.squareup.Card$Brand. However, I could not find that class in the given package. But I do see that class in the nonce-api-1.4.0 package. I’m trying to figure out how to resolve this.

Sorry to hear you’re getting this error! Can you share how you’ve set up your build.gradle file? Presumably you’ve looked at the install SDK guide already: https://developer.squareup.com/docs/in-app-payments-sdk/installation?

Sorry, I’m going through the process of getting this to work with Xamarin, so I’m pulling the jar files. I found the answer to my issue pretty soon after posting. I didn’t pull all the dependency jar files for the in-app payments sdk, the one related to this issue being the com.squareup.android.card package. I now face the following runtime error at the moment:

E/AndroidRuntime( 8081): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tekwavesolutions.host/sqip.internal.CardEntryActivity}: kotlin.UninitializedPropertyAccessException: lateinit property providerContext has not been initialized

I know I’m implementing with Xamarin, which there is no current support from Square, but I was wondering if maybe this is an underlying issue.

@shay Hiya, also trying to get this working on Xamarin and have exactly the same issue. regarding In-App Payments: Error ('Failed resolution of: Lcom/squareup/Card$Brand;') when calling StartCardEntryActivity

Can you please let me know the jar file you used to resolve this? I cannot find anything for com.squareup.android.card

I found it here

https://sdk.squareup.com/public/android/com/squareup/android/card/

Good luck!

Hi @shay I got it :slight_smile: and was able to add it correctly, did you get the your square Xamarin.Android binding working? Ive got it working on iOS but not android and I’ve been spending the last few days on this and I continue to run into exceptions of missing method etc.

Currently getting an exception with Dagger and I added the Xamarin.Google.Dagger plugin into the consuming android project but no luck still:

Java.Lang.NoSuchMethodError: 'No static method checkBuilderRequirement(Ljava/lang/Object;Ljava/lang/Class;)V in class Ldagger/internal/Preconditions; or its super classes (declaration of 'dagger.internal.Preconditions' appears in /data/app/com.companyname.test-WeKSOWpRsWlY8Nce20ApUw==/base.apk)'

You can see from below I have included whats needed i.e. jars and aar files, anything look missing from yours if you got this working?

The above and ‘Failed resolution of: Ldagger/internal/Factory;’ are my current exception issues. But its all Dagger related, the internals all seem to be using Dagger so have added in the references to them but still no luck. If you have a working solution are you able to share it?

It’s funny you say that cause I had it working on Android, but not iOS :smile:. We ended up moving to Stripe. Unfortunately, I did not save the work that was done for Android. Maybe this would help?

https://sdk.squareup.com/public/android/com/squareup/dagger2/dagger/2.19.1/

I found that alot of issues with the android binding were resolved by looking for packages that reside in the Index of public-android/com/squareup directory.

Bugger, well once I get this working ill make a nuget out of it :slight_smile: did you by any chance remember if you added the Xamarin.Google.Dagger package from Nuget or rely completely on the dagger jar provided in this SDK? Ive seen some posts mentioning that Xamarin.Google.Dagger should be included but I’m not fully convinced. keep getting exception with dagger

I believe it was included