x00yan00
tenny阳
2017-10-09 07:56

[jacoco] 找不到类 "org.jacoco.agent.rt.RT",求解答

10
  • 插件

使用android stuido进行功能测试代码覆盖率统计。
jacoco应该是gradle自带的一个插件。但是运行的时候提示找不到对应的类。自己创建一个hello world项目进行测试又很正常。
build.gradle中配置如下:
apply plugin: 'jacoco'
buildTypes {
debug {
testCoverageEnabled = true
...
}
}

报错如下:
D/JacocoInstrumentation:(22005): java.lang.ClassNotFoundException: org.jacoco.agent.rt.RT
D/JacocoInstrumentation:(22005): at java.lang.Class.classForName(Native Method)
D/JacocoInstrumentation:(22005): at java.lang.Class.forName(Class.java:309)
D/JacocoInstrumentation:(22005): at java.lang.Class.forName(Class.java:273)
D/JacocoInstrumentation:(22005): at com.inveno.xiaozhi.test.JacocoInstrumentation.generateCoverageReport(JacocoInstrumentation.java:88)
D/JacocoInstrumentation:(22005): at com.inveno.xiaozhi.test.JacocoInstrumentation.onActivityFinished(JacocoInstrumentation.java:139)
D/JacocoInstrumentation:(22005): at com.inveno.xiaozhi.test.InstrumentedActivity.onDestroy(InstrumentedActivity.java:24)
D/JacocoInstrumentation:(22005): at android.app.Activity.performDestroy(Activity.java:6271)
D/JacocoInstrumentation:(22005): at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1148)
D/JacocoInstrumentation:(22005): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3962)
D/JacocoInstrumentation:(22005): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3993)
D/JacocoInstrumentation:(22005): at android.app.ActivityThread.access$1400(ActivityThread.java:178)
D/JacocoInstrumentation:(22005): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1524)
D/JacocoInstrumentation:(22005): at android.os.Handler.dispatchMessage(Handler.java:111)
D/JacocoInstrumentation:(22005): at android.os.Looper.loop(Looper.java:194)
D/JacocoInstrumentation:(22005): at android.app.ActivityThread.main(ActivityThread.java:5637)
D/JacocoInstrumentation:(22005): at java.lang.reflect.Method.invoke(Native Method)
D/JacocoInstrumentation:(22005): at java.lang.reflect.Method.invoke(Method.java:372)
D/JacocoInstrumentation:(22005): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
D/JacocoInstrumentation:(22005): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
D/JacocoInstrumentation:(22005): Caused by: java.lang.ClassNotFoundException: Didn't find class "org.jacoco.agent.rt.RT" on path: DexPathList[[zip file "/data/app/coms file "/data/app/com.hotoday.news-1/b", zip file "/data/app/com.hotoday.news-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.hotoday.news-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.hotoday.news-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.hotoday.news-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.hotoday.news-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.hotoday.news-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.hotoday.news-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.hotoday.news-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.hotoday.news-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.hotoday.news-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.hotoday.news-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
D/JacocoInstrumentation:(22005): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
D/JacocoInstrumentation:(22005): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
D/JacocoInstrumentation:(22005): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
D/JacocoInstrumentation:(22005): ... 19 more
D/JacocoInstrumentation:(22005): Suppressed: java.lang.ClassNotFoundException: org.jacoco.agent.rt.RT
D/JacocoInstrumentation:(22005): at java.lang.Class.classForName(Native Method)
D/JacocoInstrumentation:(22005): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
D/JacocoInstrumentation:(22005): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
D/JacocoInstrumentation:(22005): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
D/JacocoInstrumentation:(22005): ... 20 more
D/JacocoInstrumentation:(22005): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答