Java.lang.NoClassDefFoundError: Permission failed: Lorg / jacoco / agent / rt / internal_14f7ee5 / Offline

I see the following error in my Android project after upgrading to Gradle Build Tools 2.1.3 and Gradle 2.14.1. This happens immediately after starting the application. How to fix it?

java.lang.NoClassDefFoundError: Failed resolution of: Lorg/jacoco/agent/rt/internal_14f7ee5/Offline; at com.ourapp.next.conversation.SomeList.SomeListViewModel.$jacocoInit(SomeListViewModel.java) at com.ourapp.next.conversation.SomeList.SomeListViewModel.(SomeListViewModel.java) at com.ourapp.next.conversation.SomeList.SomeListAdapterTest.(SomeListAdapterTest.java:26) at java.lang.reflect.Constructor.newInstance(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:288) at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217) at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at org.junit.runner.JUnitCore.run(JUnitCore.java:115) at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:59) at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:262) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1853) Caused by: java.lang.ClassNotFoundException: Didn't find class "org.jacoco.agent.rt.internal_14f7ee5.Offline" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.ourapp.next.debug.test-1/base.apk", zip file "/data/app/com.ourapp.next.debug-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) ... 30 more Suppressed: java.lang.ClassNotFoundException: org.jacoco.agent.rt.internal_14f7ee5.Offline at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 31 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available 
+5
source share
3 answers

An error report was sent: https://code.google.com/p/android/issues/detail?id=220640

This seems like a problem with jacoco versions. You need to update jacocoversion to 0.7.6.201602180812 .

To quote a post:

The jacoco plugin version was removed from 0.7.4.201502262128 to 0.7.6.201602180812 between 2.1.2 and 2.1.3, which is the likely cause of this problem.

In 2.2, this is 0.7.5.201505241946.

It seems that one of the possible errors may be related to the Google Play services. There are currently temporary workarounds.

Option 1 : comment testCoverageEnabled true .

 buildTypes { debug { // testCoverageEnabled true } } 

Option 2 : Using Instant Run also seems to solve this problem.

+14
source

For those who encounter this error when running a user interface test with jacoco code coverage using the createDebugCoverageReport task

Adding this jar fixes this problem.

Missing Jar Jacobo Components

Answer taken from

fooobar.com/questions/1255613 / ...

I ran into this error when running a user interface test covering the android library project with the Android application project. The whole thing worked fine, only the android library project ran into this problem

0
source

I think I have found a better solution to this problem. For some reason, jacoco-agent.jar does not turn on by default, and it has an Offline.class parameter that cannot be found. You just need to add the dependency for the agent. However, make sure that it is exactly the same version as the version of the jacoco plugin you are using, since the final package Offline.class is in a commit hash. That's what I'm doing:

compile 'org.jacoco: jacoco-maven-plugin: 0.7.9'

compile 'org.jacoco: org.jacoco.agent: 0.7.9: runtime

0
source

All Articles