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

java.lang.NoClassDefFoundError (Mix of API levels) #92

Closed
mustafaozhan opened this issue Jan 6, 2021 · 5 comments
Closed

java.lang.NoClassDefFoundError (Mix of API levels) #92

mustafaozhan opened this issue Jan 6, 2021 · 5 comments

Comments

@mustafaozhan
Copy link

Hello I saw closed issues with desugaring for Android but my issue seems not fixed with it.

I moved my Android project to Kotlin Multi Platform and current modules for the android project are below:

android -> client(KMP) -> common(KMP)

android doesn't implement kotlinx-datetime directly but client and common has it and uses. When I applied desugaring to only android it didn't work and I applied to all these 3 modules (with Java8 support). this is a branch that you can check.

I just created a build from mentioned branch and published for internal testing (by this way Google runs it in couple of devices)
I have crashes from below android versions

  • 5.0.1
  • 6.0.1
  • 8.0.0 (SDK 26)
  • 8.1.0
  • 9

Here is the original crash report from Firebase

Fatal Exception: java.lang.NoClassDefFoundError: Failed resolution of: Lj$/time/Instant;
       at kotlinx.datetime.Instant.<clinit>(Instant.kt:78)
       at kotlinx.datetime.Clock$System.now(Clock.kt:17)
       at com.github.mustafaozhan.ccc.common.data.settings.SettingsRepository.getLastReviewRequest(SettingsRepository.kt:36)
       at com.github.mustafaozhan.ccc.client.viewmodel.main.MainViewModel.shouldShowReview(MainViewModel.kt:19)
       at com.github.mustafaozhan.ccc.android.ui.MainActivity.checkReview(MainActivity.kt:92)
       at com.github.mustafaozhan.ccc.android.ui.MainActivity.onCreate(MainActivity.kt:48)
       at android.app.Activity.performCreate(Activity.java:6013)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
       at androidx.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:2)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2359)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2466)
       at android.app.ActivityThread.access$1200(ActivityThread.java:152)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1341)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at androidx.test.espresso.base.Interrogator.a(Interrogator.java:11)
       at androidx.test.espresso.base.UiControllerImpl.n(UiControllerImpl.java:6)
       at androidx.test.espresso.base.UiControllerImpl.m(UiControllerImpl.java:1)
       at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:6)
       at androidx.test.espresso.action.MotionEvents.a(MotionEvents.java:15)
       at androidx.test.espresso.action.Tap.b(Tap.java)
       at androidx.test.espresso.action.Tap$1.sendTap(Tap.java:1)
       at androidx.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:4)
       at androidx.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:4)
       at androidx.test.espresso.ViewInteraction.a(ViewInteraction.java)
       at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5538)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
       
       Caused by java.lang.ClassNotFoundException: Didn't find class "j$.time.Instant" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/androidx.test.tools.crawler-1/base.apk", zip file "/data/app/mustafaozhan.git.luolix.top.mycurrencies-1/base.apk", zip file "/data/app/mustafaozhan.git.luolix.top.mycurrencies-1/split_config.xhdpi.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
       at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
       at kotlinx.datetime.Instant.<clinit>(Instant.kt:78)
       at kotlinx.datetime.Clock$System.now(Clock.kt:17)
       at com.github.mustafaozhan.ccc.common.data.settings.SettingsRepository.getLastReviewRequest(SettingsRepository.kt:36)
       at com.github.mustafaozhan.ccc.client.viewmodel.main.MainViewModel.shouldShowReview(MainViewModel.kt:19)
       at com.github.mustafaozhan.ccc.android.ui.MainActivity.checkReview(MainActivity.kt:92)
       at com.github.mustafaozhan.ccc.android.ui.MainActivity.onCreate(MainActivity.kt:48)
       at android.app.Activity.performCreate(Activity.java:6013)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
       at androidx.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:2)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2359)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2466)
       at android.app.ActivityThread.access$1200(ActivityThread.java:152)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1341)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at androidx.test.espresso.base.Interrogator.a(Interrogator.java:11)
       at androidx.test.espresso.base.UiControllerImpl.n(UiControllerImpl.java:6)
       at androidx.test.espresso.base.UiControllerImpl.m(UiControllerImpl.java:1)
       at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:6)
       at androidx.test.espresso.action.MotionEvents.a(MotionEvents.java:15)
       at androidx.test.espresso.action.Tap.b(Tap.java)
       at androidx.test.espresso.action.Tap$1.sendTap(Tap.java:1)
       at androidx.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:4)
       at androidx.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:4)
       at androidx.test.espresso.ViewInteraction.a(ViewInteraction.java)
       at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5538)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Thanks in advance!

@developer--
Copy link

Same for me

@dkhalanskyjb
Copy link
Collaborator

Thank you for the report! I did manage to reproduce the crash when running the release apk in the Android Emulator for 8.0 (the debug apk seems to work fine). Looking into this.

@mustafaozhan
Copy link
Author

Ohh actually that's right to be when i was testing it was okay too :) Thanks, as you can imagine it is a release blocker 😓

@dkhalanskyjb
Copy link
Collaborator

Could you try explicitly adding a dependency on kotlinx-datetime in android/build.gradle.kts? It seems to have fixed the issue in my small reproducing project.

@mustafaozhan
Copy link
Author

@dkhalanskyjb Thank you for checking it 👍 I confirm that i didn't received any error so far, closing the issue

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

No branches or pull requests

3 participants