Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] KOIN Injection Crash When Using Stripe Android Version 20.0.1 #4922

Closed
Dimmondback opened this issue Apr 27, 2022 · 8 comments
Closed
Assignees
Labels

Comments

@Dimmondback
Copy link

Summary

We are using KOIN for DI and are encountering a crash with our splash screen's ViewModel on startup with version 20.0.1. When using version 20.0.0, this crash does not occur.

Code to reproduce

Stack Trace:
2022-04-27 13:04:29.067 15887-15887/com.carvana.carvanaTest E/AndroidRuntime: FATAL EXCEPTION: main Process: com.carvana.carvanaTest, PID: 15887 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.carvana.carvanaTest/com.carvana.carvana.features.splash.SplashActivity}: java.lang.RuntimeException: Cannot create an instance of class com.carvana.carvana.features.splash.SplashViewModel at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3707) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3864) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2253) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7870) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) Caused by: java.lang.RuntimeException: Cannot create an instance of class com.carvana.carvana.features.splash.SplashViewModel at androidx.lifecycle.ViewModelProvider$NewInstanceFactory.create(ViewModelProvider.kt:201) at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.kt:319) at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.kt:275) at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.kt:184) at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.kt:153) at com.carvana.carvana.features.splash.SplashActivity$special$$inlined$getViewModel$default$1.invoke(AnyExt.kt:53) at com.carvana.carvana.features.splash.SplashActivity$special$$inlined$getViewModel$default$1.invoke(AnyExt.kt:45) at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) at com.carvana.carvana.features.splash.SplashActivity.getViewModel(SplashActivity.kt:27) at com.carvana.carvana.features.splash.SplashActivity.setupObserver(SplashActivity.kt:137) at com.carvana.carvana.features.splash.SplashActivity.onCreate(SplashActivity.kt:79) at android.app.Activity.performCreate(Activity.java:8054) at android.app.Activity.performCreate(Activity.java:8034) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1341) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3688) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3864)  at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2253)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loopOnce(Looper.java:201)  at android.os.Looper.loop(Looper.java:288)  at android.app.ActivityThread.main(ActivityThread.java:7870)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)  Caused by: java.lang.InstantiationException: java.lang.Class<com.carvana.carvana.features.splash.SplashViewModel> has no zero argument constructor at java.lang.Class.newInstance(Native Method) at androidx.lifecycle.ViewModelProvider$NewInstanceFactory.create(ViewModelProvider.kt:199) at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.kt:319)  at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.kt:275)  at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.kt:184)  at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.kt:153)  at com.carvana.carvana.features.splash.SplashActivity$special$$inlined$getViewModel$default$1.invoke(AnyExt.kt:53)  at com.carvana.carvana.features.splash.SplashActivity$special$$inlined$getViewModel$default$1.invoke(AnyExt.kt:45)  at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)  at com.carvana.carvana.features.splash.SplashActivity.getViewModel(SplashActivity.kt:27)  at com.carvana.carvana.features.splash.SplashActivity.setupObserver(SplashActivity.kt:137)  at com.carvana.carvana.features.splash.SplashActivity.onCreate(SplashActivity.kt:79)  at android.app.Activity.performCreate(Activity.java:8054)  at android.app.Activity.performCreate(Activity.java:8034)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1341)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3688)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3864)  at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2253)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loopOnce(Looper.java:201)  at android.os.Looper.loop(Looper.java:288)  at android.app.ActivityThread.main(ActivityThread.java:7870)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

Android version

Android 10, 12.

Impacted devices

Test device Pixel 6 Pro. Emulator Pixel 5 API 29.

Installation method

Through gradle dependency.

kotlin: 1.6.10
stripe-android: 20.0.1
Android Gradle Plugin: 7.0.4
Gradle: Gradle 7.3

SDK classes

Version 20.0.0 works while version 20.0.1 crashes.

@brnunes-stripe
Copy link
Contributor

Hi @Dimmondback, thanks for filing the bug.
I don't see any reference to our SDK's classes in the stacktrace. The crash is caused by not being able to instantiate SplashViewModel without any arguments.

Caused by: java.lang.InstantiationException: java.lang.Class<com.carvana.carvana.features.splash.SplashViewModel> has no zero argument constructor at java.lang.Class.newInstance(Native Method) at

What are the arguments that the constructor takes? What SDK methods do you call during initialization?

@Dimmondback
Copy link
Author

SplashViewModel has arguments being passed in via DI and no such constructor/method exists with 0 arguments.

For Stripe's SDK methods, I haven't included any functional code yet. This is just with importing the Stripe dependency into Gradle and running the project. The only code difference is when I switch between 20.0.0 and 20.0.1 for the dependency.

@brnunes-stripe
Copy link
Contributor

brnunes-stripe commented May 2, 2022

Hi @Dimmondback,
I couldn't reproduce this crash by just importing the SDK. Your stack trace doesn't have any reference to the Stripe SDK, so it doesn't give any indication that this is happening because of our SDK, or what is happening.
Can you try upgrading to our most recent version, v20.2.0?
I'm using this version without any issues, with
Kotlin 1.6.10
Android Gradle Plugin Version 7.1.3
Gradle Version 7.3.2

@brnunes-stripe
Copy link
Contributor

Hi @Dimmondback,
We suspect this might have to do with some dependency that was updated on v20.0.1, and your app is depending on some other version of it. Can you run ./gradlew :dependencies from your project's root folder and paste the result here?

@brnunes-stripe
Copy link
Contributor

Hi @Dimmondback,
We expect that #4966 will fix this. We'll release a new version early next week, please try it out and let us know.

@Dimmondback
Copy link
Author

Yes we are indeed running a different version of lifecycle dependencies. Our current version is 2.3.1 for androidx.lifecycle.

@brnunes-stripe
Copy link
Contributor

Hello,
We've released v20.2.2 today. It depends on androidx.lifecycle v2.4.1 and androidx.navigation v2.4.2.
We believe the issue was due to the dependency on androidx.navigation v2.5.0-beta01 which was pulling androidx.lifecycle v2.5.0-beta01 too.
Please try using this new release and let us know if the issue persists.

@brnunes-stripe brnunes-stripe self-assigned this May 9, 2022
@Dimmondback
Copy link
Author

v20.2.2 works perfectly! Thank you @brnunes-stripe! It seems the new version of lifecycle+navigation causes issues with our app. I will bring this up with the other engineers. Thank you again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants