I am trying to write a robolectric unit test within a library (extendlibrary) that depends on another library (baselibrary). Whenever a method in baselibrary tries to access its resource file I get the following error.
java.lang.NoClassDefFoundError: robolectricdemo/com/baselibrary/R$color at robolectricdemo.com.baselibrary.DemoStaticClass.getDemoResource(DemoStaticClass.java:12) at LibraryResourceTest.setUp(LibraryResourceTest.java:25)
Caused by:
java.lang.ClassNotFoundException: robolectricdemo.com.baselibrary.R$color
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.robolectric.internal.bytecode.InstrumentingClassLoader.loadClass(InstrumentingClassLoader.java:98)
... 2 more
I noticed in the build directory that an R file is only being generated in the package extendlibrary but there is no package for baselibrary. Manually create the R file in a package called baselibrary causes the test to pass. Any ideas on what I could be doing wrong. Posted source at http://ift.tt/1JP9DXo
Update referencing the baselibrarys R file directly in LibraryResourceTest also causes an error saying the R file does not exisit.
Aucun commentaire:
Enregistrer un commentaire