简体   繁体   English

java.lang.NoClassDefFoundError:解析失败:Lorg/jacoco/agent/rt/internal_14f7ee5/Offline

[英]java.lang.NoClassDefFoundError: Failed resolution of: Lorg/jacoco/agent/rt/internal_14f7ee5/Offline

I'm seeing the following error in my Android project after updating to Gradle Build Tools 2.1.3 and Gradle 2.14.1.更新到 Gradle Build Tools 2.1.3 和 Gradle 2.14.1 后,我在我的 Android 项目中看到以下错误。 It happens immediately when I run the application.当我运行应用程序时,它会立即发生。 How do I fix this?我该如何解决?

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

There was a bug report filed: https://code.google.com/p/android/issues/detail?id=220640提交了一个错误报告: https ://code.google.com/p/android/issues/detail?id=220640

This looks to be a problem with jacoco versions.这看起来是 jacoco 版本的问题。 You'll need to update your jacocoversion to 0.7.6.201602180812 .您需要将 jacocoversion 更新为0.7.6.201602180812

To quote from the issue:引用这个问题:

The jacoco plugin version was bumped from 0.7.4.201502262128 to 0.7.6.201602180812 between 2.1.2 to 2.1.3 which is the likely cause of this issue. jacoco 插件版本在 2.1.2 到 2.1.3 之间从 0.7.4.201502262128 增加到 0.7.6.201602180812,这可能是导致此问题的原因。

In 2.2 it is 0.7.5.201505241946.在 2.2 中,它是 0.7.5.201505241946。

It also looks like one possible error might be related to Google Play Services.看起来一个可能的错误可能与 Google Play 服务有关。 There are temporary workarounds for the time being.暂时有临时的解决方法。

Option 1 : Comment out testCoverageEnabled true .选项 1 :注释掉testCoverageEnabled true

buildTypes {
    debug {
        // testCoverageEnabled true
    }
}

Option 2 : Using Instant Run also seems to solve this problem.选项 2 :使用 Instant Run 似乎也可以解决这个问题。

I think I found the best solution to this issue.我想我找到了解决这个问题的最佳方法。 For some reason the jacoco-agent.jar does not get included by default and it has the Offline.class that can't be found.由于某种原因,默认情况下不包含 jacoco-agent.jar,并且它具有无法找到的 Offline.class。 You simply need to add the dependency for the agent.您只需添加代理的依赖项。 However, make sure it is the exact same version as the version of the jacoco plugin you are using since the end package Offline.class is found in is a commit hash.但是,请确保它与您正在使用的 jacoco 插件的版本完全相同,因为找到的最终包 Offline.class 是一个提交哈希。 Here is what I am doing:这是我正在做的事情:

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

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

For anyone facing this error while running UI Test with jacoco code coverage using createDebugCoverageReport task对于使用createDebugCoverageReport任务运行带有 jacoco 代码覆盖率的 UI 测试时遇到此错误的任何人

Adding this jar solved this problem添加这个jar解决了这个问题

Missing Jacoco Components Jar 缺少 Jacoco 组件罐

Answer taken from答案取自

https://stackoverflow.com/a/42698722/3053781 https://stackoverflow.com/a/42698722/3053781

I was facing this error while running UI test with coverage on android library project with android application project every thing was working fine only android library project was facing this issue我在使用 android 应用程序项目运行覆盖 android 库项目的 UI 测试时遇到了这个错误,每件事都工作正常只有 android 库项目面临这个问题

I had the same issue with AGP 7.2.1 and Jacoco 0.8.7.我对 AGP 7.2.1 和 Jacoco 0.8.7 也有同样的问题。

Adding this dependency to my app/build.gradle fixed it:将此依赖项添加到我的 app/build.gradle 修复了它:

debugImplementation 'androidx.fragment:fragment-testing:1.4.1'

After two days of searching for a solution, finally found this!找了两天解决办法,终于找到了! just need to add this dependency:只需要添加这个依赖:

implementation "org.jacoco:org.jacoco.agent:0.8.7:runtime"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.NoClassDefFoundError:解析失败:Lorg/jacoco/agent/rt/internal_773e439/Offline; - java.lang.NoClassDefFoundError: Failed resolution of: Lorg/jacoco/agent/rt/internal_773e439/Offline; 解析失败:Lorg/jacoco/agent/rt/internal_8ff85ea/Offline - Failed resolution of: Lorg/jacoco/agent/rt/internal_8ff85ea/Offline Android App 中的异常:Lorg/jacoco/agent/rt/internal_8ff85ea/Offline 的解析失败; - Exception in Android App: Failed resolution of: Lorg/jacoco/agent/rt/internal_8ff85ea/Offline; 如何将 jacocoagent.jar 添加到 Android build.gradle - Failed resolution of: Lorg/jacoco/agent/rt/internal_3570298/Offline; - How to add jacocoagent.jar to Android build.gradle - Failed resolution of: Lorg/jacoco/agent/rt/internal_3570298/Offline; java.lang.NoClassDefFoundError:解析失败:Lorg/apache/http/ProtocolVersion - java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion java.lang.NoClassDefFoundError:无法解决以下问题:Lorg / apache / http / params / BasicHttpParams; - java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/params/BasicHttpParams; Koin java.lang.NoClassDefFoundError:解析失败:Lorg/koin/dsl/context/ParameterHolderKt - Koin java.lang.NoClassDefFoundError: Failed resolution of: Lorg/koin/dsl/context/ParameterHolderKt Android 谷歌地图 java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion - Android Google maps java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion 错误:java.lang.NoClassDefFoundError:无法解决以下问题:Lorg / apache / xmlbeans / XmlOptions; - error: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/xmlbeans/XmlOptions; java.lang.NoClassDefFoundError:解析失败:Lorg / junit / runner / notification / RunListener - java.lang.NoClassDefFoundError: Failed resolution of: Lorg/junit/runner/notification/RunListener
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM