我试图在我使用谷歌排球图书馆的项目上运行roboelectric,我一直在 当我尝试使用简单的字符串检查运行测试项目时出现相同的错误
java.lang.RuntimeException: java.lang.ClassNotFoundException: com.android.volley.R
at org.robolectric.AndroidManifest.getRClass(AndroidManifest.java:79)
at org.robolectric.AndroidManifest.getResourcePath(AndroidManifest.java:233)
at org.robolectric.AndroidManifest.getIncludedResourcePaths(AndroidManifest.java:238)
at org.robolectric.AndroidManifest.getIncludedResourcePaths(AndroidManifest.java:240)
at org.robolectric.RobolectricTestRunner.createAppResourceLoader(RobolectricTestRunner.java:422)
at org.robolectric.RobolectricTestRunner.getAppResourceLoader(RobolectricTestRunner.java:411)
at org.robolectric.RobolectricTestRunner.setupApplicationState(RobolectricTestRunner.java:188)
at org.robolectric.RobolectricTestRunner.internalBeforeTest(RobolectricTestRunner.java:134)
at org.robolectric.RobolectricTestRunner.methodBlock(RobolectricTestRunner.java:92)
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.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)
Caused by: java.lang.ClassNotFoundException: com.android.volley.R
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.robolectric.AndroidManifest.getRClass(AndroidManifest.java:77)
... 22 more
我的项目使用android target sdk 16。
感谢。
答案 0 :(得分:0)
通过删除volley库并将Volley.jar文件从其bin文件夹复制到我的Main项目libs文件夹并将其添加到构建路径来解决此异常
答案 1 :(得分:0)
这太迟了,但是对于新来者来说,这是与volley和android studio集成的一个错误,但是如果您使用新版本,它将自动解决implementation 'com.android.volley:volley:1.1.1