In-App Payment Android: java.lang.RuntimeException: Unable to start activity ComponentInfo

Card Activity is not opening. Below is the crash logs.

2020-12-29 22:42:11.023 12203-12203/com.links.fitness E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.links.fitness, PID: 12203
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.links.fitness/sqip.internal.CardEntryActivity}: java.lang.IllegalArgumentException: Cannot serialize Kotlin type sqip.internal.nonce.CreateCardNonceErrorResponse. Reflective serialization of Kotlin classes without using kotlin-reflect has undefined and unexpected behavior. Please use KotlinJsonAdapter from the moshi-kotlin artifact or use code gen from the moshi-kotlin-codegen artifact.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2925)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3060)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1818)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6762)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.IllegalArgumentException: Cannot serialize Kotlin type sqip.internal.nonce.CreateCardNonceErrorResponse. Reflective serialization of Kotlin classes without using kotlin-reflect has undefined and unexpected behavior. Please use KotlinJsonAdapter from the moshi-kotlin artifact or use code gen from the moshi-kotlin-codegen artifact.
at com.squareup.moshi.ClassJsonAdapter$1.create(ClassJsonAdapter.java:83)
at com.squareup.moshi.Moshi.adapter(Moshi.java:138)
at com.squareup.moshi.Moshi.adapter(Moshi.java:98)
at retrofit2.converter.moshi.MoshiConverterFactory.responseBodyConverter(MoshiConverterFactory.java:91)
at retrofit2.Retrofit.nextResponseBodyConverter(Retrofit.java:352)
at retrofit2.Retrofit.responseBodyConverter(Retrofit.java:335)
at sqip.internal.HttpModule.cardNonceErrorConverter(HttpModule.kt:61)
at sqip.internal.HttpModule_CardNonceErrorConverterFactory.proxyCardNonceErrorConverter(HttpModule_CardNonceErrorConverterFactory.java:38)
at sqip.internal.HttpModule_CardNonceErrorConverterFactory.provideInstance(HttpModule_CardNonceErrorConverterFactory.java:27)
at sqip.internal.HttpModule_CardNonceErrorConverterFactory.get(HttpModule_CardNonceErrorConverterFactory.java:22)
at sqip.internal.HttpModule_CardNonceErrorConverterFactory.get(HttpModule_CardNonceErrorConverterFactory.java:12)
at sqdagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at sqip.internal.nonce.CreateCardNonceRequestHandler_Real_Factory.provideInstance(CreateCardNonceRequestHandler_Real_Factory.java:64)
at sqip.internal.nonce.CreateCardNonceRequestHandler_Real_Factory.get(CreateCardNonceRequestHandler_Real_Factory.java:46)
at sqip.internal.nonce.CreateCardNonceRequestHandler_Real_Factory.get(CreateCardNonceRequestHandler_Real_Factory.java:13)
at sqdagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at sqip.internal.CardEntryActivityController_Factory.provideInstance(CardEntryActivityController_Factory.java:37)
at sqip.internal.CardEntryActivityController_Factory.get(CardEntryActivityController_Factory.java:29)
at sqip.internal.CardEntryActivityController_Factory.get(CardEntryActivityController_Factory.java:10)
at sqdagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at sqip.internal.nonce.DaggerCardEntryActivityComponent.cardEntryActivityController(DaggerCardEntryActivityComponent.java:209)
at sqip.internal.CardEntryActivity.onCreate(CardEntryActivity.kt:128)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
2020-12-29 22:42:11.023 12203-12203/com.links.fitness E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2905)
… 11 more

Gradle dependencies:

implementation ‘com.squareup.sdk.in-app-payments:card-entry:1.4.0’
implementation ‘com.squareup.sdk.in-app-payments:google-pay:1.2.0’
implementation ‘com.google.android.gms:play-services-wallet:16.0.1’

Please assist.

Hi @Piyush welcome to the forums!

Unfortunately this is due to the In-App Payments SDK using an oldest moshi version at the moment. Work is being done here to get it updated, but in the meantime as a workaround, can you use an older retrofit version of 2.6.0? This should unblock you for now and get you up and running.

@sjosey, Thank you
Tried with retrofit version 2.6.0, but getting the same error.

Hmmm, would you be able to also try using com.squareup.retrofit2:converter-moshi:2.6.0 as well and see if that makes a difference?

Yes, i tried with
implementation ‘com.squareup.retrofit2:converter-moshi:2.6.0’ and
implementation “com.squareup.retrofit2:retrofit:2.6.0”

set both to version 2.6.0 but still crashing

Dang, thanks for confirming. Could you paste a full list of all your dependencies here, please?

Here is full list of dependencies :

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

//Testing libs
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
implementation 'androidx.core:core-ktx:1.3.2'

//Dependency Injection
implementation "com.google.dagger:dagger:2.28"
implementation "com.google.dagger:dagger-android-support:2.28"
kapt "com.google.dagger:dagger-compiler:2.28"
kapt "com.google.dagger:dagger-android-processor:2.28"


//RxJava
implementation "io.reactivex.rxjava2:rxjava:2.2.12"
implementation "io.reactivex.rxjava2:rxandroid:2.0.2"
implementation "com.jakewharton.retrofit:retrofit2-rxjava2-adapter:2.6.0"

//Network
implementation "com.squareup.okhttp3:okhttp:3.10.0"
implementation "com.squareup.okhttp3:logging-interceptor:3.8.1"
implementation "com.squareup.retrofit2:retrofit:2.6.0"
implementation "com.squareup.retrofit2:converter-gson:2.6.0"
implementation "com.squareup.retrofit2:adapter-rxjava:2.6.0"
implementation 'com.github.rtchagas:pingplacepicker:2.0.0'

// view model
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"

implementation 'com.github.bumptech.glide:glide:4.11.0'
kapt 'com.github.bumptech.glide:compiler:4.11.0'

implementation 'com.google.android.gms:play-services-location:17.1.0'
implementation 'com.google.android.gms:play-services-auth:18.1.0'
implementation 'com.google.firebase:firebase-analytics:17.5.0'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
implementation 'com.google.firebase:firebase-messaging:20.2.4'
//Payment SDK
implementation 'com.squareup.sdk.in-app-payments:card-entry:1.2.0'
implementation 'com.squareup.sdk.in-app-payments:google-pay:1.2.0'
implementation 'com.google.android.gms:play-services-wallet:16.0.1'
implementation 'com.squareup.retrofit2:converter-moshi:2.6.0'

}

Could you try adding com.squareup.moshi:moshi-kotlin:1.8.0 to your dependencies and let me know what happens?

Problem is with implementation 'com.github.rtchagas:pingplacepicker:2.0.0'
It’s using retrofit version 2.7.1

If I removed it, CardActivity is opening