1

I'm trying to run roboelectric on my project that is using google Volley library and i keep getting the same error when i try running the test project with a simple string check

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

my project uses android target sdk 16.

Thanks.

shimi_tap
  • 7,822
  • 5
  • 23
  • 23

2 Answers2

0

This Exception was solved by removing the volley library and copying the Volley.jar file from its bin folder to my Main project libs folder and adding it to build path

shimi_tap
  • 7,822
  • 5
  • 23
  • 23
0

It super late but for new Comers , this was a bug in the integration with volley and android studio , but if you use new version it will automatically solve it implementation 'com.android.volley:volley:1.1.1

mazen amr
  • 90
  • 6