gpt4 book ai didi

robolectric - Robolectric 2.2 错误

转载 作者:行者123 更新时间:2023-12-04 03:27:55 25 4
gpt4 key购买 nike

我在使用 roboelectric 2.2 时遇到以下错误

java.lang.IncompatibleClassChangeError: class org.objectweb.asm.tree.ClassNode has interface org.objectweb.asm.ClassVisitor as super class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.robolectric.RobolectricTestRunner.createRobolectricClassLoader(RobolectricTestRunner.java:144)
at org.robolectric.RobolectricTestRunner.createSdkEnvironment(RobolectricTestRunner.java:116)
at org.robolectric.RobolectricTestRunner$3.create(RobolectricTestRunner.java:279)
at org.robolectric.EnvHolder.getSdkEnvironment(EnvHolder.java:21)
at org.robolectric.RobolectricTestRunner.getEnvironment(RobolectricTestRunner.java:277)
at org.robolectric.RobolectricTestRunner.access$100(RobolectricTestRunner.java:57)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:188)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:175)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

我是用网站配置的 http://www.androiddevelopersolution.com/2013/03/android-unit-testing-with-robolectric.html

我在应用程序和测试项目中使用了 android jar 文件。有什么建议?谢谢你。

最佳答案

是的,我遇到了同样的问题,asm正如@thoutisbeckers 所说,版本问题。尝试这个:

dependencies {
androidTestCompile 'org.robolectric:robolectric:2.+'
androidTestCompile 'junit:junit:4.+'
compile 'org.ow2.asm:asm:4.0'
compile ('org.roboguice:roboguice:2.0') {
exclude module: 'asm'
}
}

关于robolectric - Robolectric 2.2 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19471704/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com