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.