Issue
Problem
So I integrated Jetpack Compose dependencies in the application module. But the below exception is occurring whenever the app is started/launched. It's failing in the Application
class.
Stacktrace:
2021-10-22 11:16:01.079 16281-16281/com.example E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example, PID: 16281
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/jacoco/agent/rt/internal_8ff85ea/Offline;
at com.example.app.MyApplication.attachBaseContext(MyApplication.java:719)
at android.app.Application.attach(Application.java:361)
at android.app.Instrumentation.newApplication(Instrumentation.java:1159)
at android.app.LoadedApk.makeApplication(LoadedApk.java:1324)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7223)
at android.app.ActivityThread.access$1600(ActivityThread.java:298)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2172)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:264)
at android.app.ActivityThread.main(ActivityThread.java:8248)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.jacoco.agent.rt.internal_8ff85ea.Offline" on path: DexPathList[[zip file "/data/app/~~MsNoI2GIvO6hDqGPC9BKfw==/com.example-jknI-wJelwi0a-NSFCz0ig==/base.apk"]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.example.app.MyApplication.attachBaseContext(MyApplication.java:719)
at android.app.Application.attach(Application.java:361)
at android.app.Instrumentation.newApplication(Instrumentation.java:1159)
at android.app.LoadedApk.makeApplication(LoadedApk.java:1324)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7223)
at android.app.ActivityThread.access$1600(ActivityThread.java:298)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2172)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:264)
at android.app.ActivityThread.main(ActivityThread.java:8248)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)
Suppressed: java.io.IOException: No original dex files found for dex location (arm64) /data/app/~~MsNoI2GIvO6hDqGPC9BKfw==/com.example-jknI-wJelwi0a-NSFCz0ig==/split_config.arm64_v8a.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:379)
at dalvik.system.DexFile.<init>(DexFile.java:112)
at dalvik.system.DexFile.<init>(DexFile.java:85)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:439)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:398)
at dalvik.system.DexPathList.<init>(DexPathList.java:166)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:129)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:104)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:74)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:87)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:116)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:114)
at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:60)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:981)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:1038)
at android.app.LoadedApk.getResources(LoadedApk.java:1270)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2750)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2742)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7128)
2021-10-22 11:16:01.080 16281-16281/com.example E/AndroidRuntime: ... 8 more
Suppressed: java.io.IOException: No original dex files found for dex location (arm64) /data/app/~~MsNoI2GIvO6hDqGPC9BKfw==/com.example-jknI-wJelwi0a-NSFCz0ig==/split_config.xxhdpi.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:379)
at dalvik.system.DexFile.<init>(DexFile.java:112)
at dalvik.system.DexFile.<init>(DexFile.java:85)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:439)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:398)
at dalvik.system.DexPathList.<init>(DexPathList.java:166)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:129)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:104)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:74)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:87)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:116)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:114)
at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:60)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:981)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:1038)
at android.app.LoadedApk.getResources(LoadedApk.java:1270)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2750)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2742)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7128)
... 8 more
My Setup
- IDE: Android Studio Arctic Fox - Stable | Patch 3
- Java JDK 11
- Kotlin 1.5.30
- Jetpack Compose 1.0.3
- Android Gradle Plugin 7.0.2
- Gradle Wrapper Version 7.0.2
- JaCoCo Version 0.8.7
build.gradle:
jacoco {
toolVersion = "0.8.7"
}
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
buildTypes {
debug {
testCoverageEnabled true
}
}
Solution
The solution to the issue is very interesting.
Our project has remote submodules which were also using JaCoCo and in the main project we upgraded the Android Gradle Plugin version and not upgraded AGP in remote submodules then this issue was occurring. This is because those submodules also use the JaCoCo plugin.
Once we upgraded all submodules which were using the JaCoCo plugin and updated respective versions in the main application, this issue got resolved.
Earlier we were using AGP 4.2.2 and this issue was coming after upgrading AGP to 7.x.x.
Answered By - Shreyas Patil
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.