Android ClassNotFoundException,类在APK中

时间:2014-09-29 14:15:29

标签: android maven noclassdeffounderror classnotfoundexception jacoco

在模拟器上运行Android应用时出现以下错误:

I/dalvikvm( 2560): Failed resolving Lorg/jacoco/agent/rt/internal_e6e56f0/CoverageTransformer; interface 6277 'Ljava/lang/instrument/ClassFileTransformer;'
W/dalvikvm( 2560): Link of class 'Lorg/jacoco/agent/rt/internal_e6e56f0/CoverageTransformer;' failed
W/ClassPathPackageInfoSource( 2560): Cannot load class. Make sure it is in your apk. Class name: 'org.jacoco.agent.rt.internal_e6e56f0.CoverageTransformer'. Message: org.jacoco.agent.rt.internal_e6e56f0.CoverageTransformer
W/ClassPathPackageInfoSource( 2560): java.lang.ClassNotFoundException: org.jacoco.agent.rt.internal_e6e56f0.CoverageTransformer
W/ClassPathPackageInfoSource( 2560):    at java.lang.Class.classForName(Native Method)
W/ClassPathPackageInfoSource( 2560):    at java.lang.Class.forName(Class.java:217)
W/ClassPathPackageInfoSource( 2560):    at android.test.ClassPathPackageInfoSource.createPackageInfo(ClassPathPackageInfoSource.java:88)
W/ClassPathPackageInfoSource( 2560):    at android.test.ClassPathPackageInfoSource.access$000(ClassPathPackageInfoSource.java:39)
W/ClassPathPackageInfoSource( 2560):    at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:50)
W/ClassPathPackageInfoSource( 2560):    at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:47)
W/ClassPathPackageInfoSource( 2560):    at android.test.SimpleCache.get(SimpleCache.java:31)
W/ClassPathPackageInfoSource( 2560):    at android.test.ClassPathPackageInfoSource.getPackageInfo(ClassPathPackageInfoSource.java:72)
W/ClassPathPackageInfoSource( 2560):    at android.test.ClassPathPackageInfo.getSubpackages(ClassPathPackageInfo.java:48)
W/ClassPathPackageInfoSource( 2560):    at android.test.ClassPathPackageInfo.addTopLevelClassesTo(ClassPathPackageInfo.java:61)
W/ClassPathPackageInfoSource( 2560):    at android.test.ClassPathPackageInfo.getTopLevelClassesRecursive(ClassPathPackageInfo.java:55)
W/ClassPathPackageInfoSource( 2560):    at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:156)
W/ClassPathPackageInfoSource( 2560):    at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:117)
W/ClassPathPackageInfoSource( 2560):    at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:102)
W/ClassPathPackageInfoSource( 2560):    at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:366)
W/ClassPathPackageInfoSource( 2560):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4142)
W/ClassPathPackageInfoSource( 2560):    at android.app.ActivityThread.access$1300(ActivityThread.java:130)
W/ClassPathPackageInfoSource( 2560):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
W/ClassPathPackageInfoSource( 2560):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/ClassPathPackageInfoSource( 2560):    at android.os.Looper.loop(Looper.java:137)
W/ClassPathPackageInfoSource( 2560):    at android.app.ActivityThread.main(ActivityThread.java:4745)
W/ClassPathPackageInfoSource( 2560):    at java.lang.reflect.Method.invokeNative(Native Method)
W/ClassPathPackageInfoSource( 2560):    at java.lang.reflect.Method.invoke(Method.java:511)
W/ClassPathPackageInfoSource( 2560):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
W/ClassPathPackageInfoSource( 2560):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
W/ClassPathPackageInfoSource( 2560):    at dalvik.system.NativeStart.main(Native Method)
W/ClassPathPackageInfoSource( 2560): Caused by: java.lang.NoClassDefFoundError: org/jacoco/agent/rt/internal_e6e56f0/CoverageTransformer
W/ClassPathPackageInfoSource( 2560):    ... 26 more
W/ClassPathPackageInfoSource( 2560): Caused by: java.lang.ClassNotFoundException: org.jacoco.agent.rt.internal_e6e56f0.CoverageTransformer
W/ClassPathPackageInfoSource( 2560):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
W/ClassPathPackageInfoSource( 2560):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
W/ClassPathPackageInfoSource( 2560):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
W/ClassPathPackageInfoSource( 2560):    ... 26 more

显而易见的解决方案是不包含依赖关系。但是,我确实在我的pom中有maven依赖(范围:编译)。我甚至反过来反编译来源:有问题的课程在我的APK中。

感谢。

1 个答案:

答案 0 :(得分:1)

这看起来类似于我刚遇到的问题。你没有运行应用程序,你正在测试它,对吗?如果是,并且您的测试正在运行,则可以忽略这些消息。请参阅讨论here