Reputation: 23503
I have a situation where I cannot debug local variables because in my gradle file I have testCoverageEnabled true
. A number of posts have correctly suggested that this should be set to false
. The issue I am having is that when I do that, my app crashes with the following stacktrace:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.MyApp.pr.redesign.app, PID: 22172
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/jacoco/agent/rt/internal_773e439/Offline;
at com.MyApp.pr.eventcollector.utils.MyAppLog.$jacocoInit(Unknown Source:14)
at com.MyApp.pr.eventcollector.utils.Log.<clinit>(Unknown Source:0)
at com.MyApp.pr.eventcollector.utils.MyApp.setLevel(Unknown Source:0)
at com.MyApp.pr.MyApp.MyApp.setupLogging(MyApp.java:171)
at com.MyApp.pr.MyApp.MyApp.onCreate(MyApp.java:71)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6056)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.jacoco.agent.rt.internal_773e439.Offline" on path: DexPathList[[zip file "/data/app/com.MyApp.pr.redesign.app-FmWSRcYONdAudVVemfy_Bw==/base.apk"],nativeLibraryDirectories=[/data/app/com.MyApp.pr.redesign.app-FmWSRcYONdAudVVemfy_Bw==/lib/arm64, /data/app/com.MyApp.pr.redesign.app-FmWSRcYONdAudVVemfy_Bw==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.MyApp.pr.eventcollector.utils.MyApp.$jacocoInit(Unknown Source:14)
at com.MyApp.pr.eventcollector.utils.MyApp.<clinit>(Unknown Source:0)
at com.MyApp.pr.eventcollector.utils.MyApp.setLevel(Unknown Source:0)
at com.MyApp.pr.MyApp.MyApp.setupLogging(MyApp.java:171)
at com.MyApp.pr.MyApp.MyApp.onCreate(MyApp.java:71)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6056)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
I am assuming that this has something to do with Jacoco
, but I am not sure. Any help would be greatly appreciated!
Upvotes: 1
Views: 2935
Reputation: 23503
I found out the issue was because we are using jacoco
for our using testing:
testImplementation 'org.jacoco:org.jacoco.agent:0.7.4.201502262128:runtime'
I was able to resolve this issue by adding the jacoco
library that I was using at runtime:
implementation 'org.jacoco:org.jacoco.agent:0.7.4.201502262128:runtime'
The key is to make sure that you use the EXACT same library you are using in the app.
Upvotes: 1