NoClassDefFoundError: android/R

323 views
Skip to first unread message

Manuel

unread,
Nov 7, 2011, 6:00:32 PM11/7/11
to Robolectric
Hi!

I have followed the Eclipse tutorial to the very word, except that I
tried to integrate Robolectric with an existing Android project, not a
new one.
However, when I execute the test runner (test method taken from
tutorial), I get this Exception:

java.lang.NoClassDefFoundError: android/R
at
com.xtremelabs.robolectric.res.ResourceLoader.<init>(ResourceLoader.java:
69)
at
com.xtremelabs.robolectric.RobolectricTestRunner.createResourceLoader(RobolectricTestRunner.java:
404)
at
com.xtremelabs.robolectric.RobolectricTestRunner.setupApplicationState(RobolectricTestRunner.java:
359)
at
com.xtremelabs.robolectric.RobolectricTestRunner.internalBeforeTest(RobolectricTestRunner.java:
310)
at
com.xtremelabs.robolectric.RobolectricTestRunner.methodBlock(RobolectricTestRunner.java:
280)
at
org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:
79)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
71)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
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: android.R
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at javassist.Loader.delegateToParent(Loader.java:428)
at javassist.Loader.loadClassByDelegation(Loader.java:406)
at javassist.Loader.loadClass(Loader.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at
com.xtremelabs.robolectric.bytecode.RobolectricClassLoader.loadClass(RobolectricClassLoader.java:
72)
... 20 more

Both projects compile, and the main project starts and works on all
devices so far.
Is this a known problem with an easy fix?

Thanks & Cheers,
Manuel
Reply all
Reply to author
Forward
0 new messages