New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robolectric forces my libraries to have a res/values directory #641

Closed
mediavrog opened this Issue Aug 12, 2013 · 7 comments

Comments

Projects
None yet
7 participants
@mediavrog

mediavrog commented Aug 12, 2013

I have setup an Android project, with a sub-tests project for unit testing.
I use the "org.robolectric.Config.properties" file to point Robolectric to my correct AndroidManifest (manifest=../AndroidManifest.xml).

Now, when loading this and instantiating the Application object, Robolectric tries to load all resources from my main project, as well as related library projects. Some of them (like Android volley), don't provide any resources, yet Robolectric seems eager to load them any way and quits with an Exception

DEBUG: Loading resources for com.my.project from ./../res...
DEBUG: Loading resources for com.viewpagerindicator from ./../../Android-ViewPagerIndicator/library/res...
DEBUG: Loading resources for com.facebook.android from ./../../facebook-android-sdk-3.0.1/facebook/res...
java.lang.RuntimeException: java.lang.RuntimeException: ./../../volley/res/values is not a directory
    at org.robolectric.res.PackageResourceLoader.doInitialize(PackageResourceLoader.java:23)
    at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
    at org.robolectric.res.OverlayResourceLoader.doInitialize(OverlayResourceLoader.java:22)
    at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
    at org.robolectric.res.XResourceLoader.getValue(XResourceLoader.java:53)
    at org.robolectric.res.OverlayResourceLoader.getValue(OverlayResourceLoader.java:56)
    at org.robolectric.res.RoutingResourceLoader.getValue(RoutingResourceLoader.java:31)
    at org.robolectric.shadows.ShadowAssetManager.getAndResolve(ShadowAssetManager.java:263)
    at org.robolectric.shadows.ShadowAssetManager.getResourceTextArray(ShadowAssetManager.java:100)
    at org.robolectric.shadows.ShadowAssetManager.getResourceStringArray(ShadowAssetManager.java:74)
    at android.content.res.AssetManager.getResourceStringArray(AssetManager.java)
    at android.content.res.Resources.getStringArray(Resources.java:446)
    at com.my.project.App.initialize(App.java:1657)
    at com.my.project.App.onCreate(App.java:1603)
    at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:146)
    at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:387)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:227)
    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:177)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.junit.runners.Suite.runChild(Suite.java:128)
    at org.junit.runners.Suite.runChild(Suite.java:24)
    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.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.RuntimeException: ./../../volley/res/values is not a directory
    at org.robolectric.res.DocumentLoader.load(DocumentLoader.java:39)
    at org.robolectric.res.PackageResourceLoader.loadEverything(PackageResourceLoader.java:31)
    at org.robolectric.res.PackageResourceLoader.doInitialize(PackageResourceLoader.java:19)
    at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
    at org.robolectric.res.OverlayResourceLoader.doInitialize(OverlayResourceLoader.java:22)
    at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
    at org.robolectric.res.XResourceLoader.getValue(XResourceLoader.java:53)
    at org.robolectric.res.OverlayResourceLoader.getValue(OverlayResourceLoader.java:56)
    at org.robolectric.res.RoutingResourceLoader.getValue(RoutingResourceLoader.java:31)
    at org.robolectric.shadows.ShadowAssetManager.getAndResolve(ShadowAssetManager.java:263)
    at org.robolectric.shadows.ShadowAssetManager.getResourceTextArray(ShadowAssetManager.java:100)
    at org.robolectric.shadows.ShadowAssetManager.getResourceStringArray(ShadowAssetManager.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.robolectric.bytecode.ShadowWrangler$ShadowMethodPlan.run(ShadowWrangler.java:455)
    at android.content.res.AssetManager.getResourceStringArray(AssetManager.java)
    at android.content.res.Resources.$$robo$$Resources_fb43_getStringArray(Resources.java:446)
    at android.content.res.Resources.getStringArray(Resources.java)
    at com.my.project.App.initialize(App.java:1657)
    at com.my.project.App.onCreate(App.java:1603)
    at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:146)
    at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:387)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:227)
    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:177)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.junit.runners.Suite.runChild(Suite.java:128)
    at org.junit.runners.Suite.runChild(Suite.java:24)
    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.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    ... 1 more

If i manually create a res/values folder in the library project, the error goes away

@JakeWharton

This comment has been minimized.

Show comment
Hide comment
@JakeWharton

JakeWharton Aug 12, 2013

Member

That may be the case. Volley is a jar, though. You can just drop the
compiled version into your libs/ folder.
On Aug 12, 2013 2:28 AM, "Maik Vlcek" notifications@github.com wrote:

I have setup an Android project, with a sub-tests project for unit testing.
I use the "org.robolectric.Config.properties" file to point Robolectric to
my correct AndroidManifest (manifest=../AndroidManifest.xml).

Now, when loading this and instantiating the Application object,
Robolectric tries to load all resources from my main project, as well as
related library projects. Some of them (like Android volley), don't provide
any resources, yet Robolectric seems eager to load them any way and quits
with an Exception

DEBUG: Loading resources for com.my.project from ./../res...DEBUG: Loading resources for com.viewpagerindicator from ./../../Android-ViewPagerIndicator/library/res...DEBUG: Loading resources for com.facebook.android from ./../../facebook-android-sdk-3.0.1/facebook/res...java.lang.RuntimeException: java.lang.RuntimeException: ./../../volley/res/values is not a directory
at org.robolectric.res.PackageResourceLoader.doInitialize(PackageResourceLoader.java:23)
at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
at org.robolectric.res.OverlayResourceLoader.doInitialize(OverlayResourceLoader.java:22)
at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
at org.robolectric.res.XResourceLoader.getValue(XResourceLoader.java:53)
at org.robolectric.res.OverlayResourceLoader.getValue(OverlayResourceLoader.java:56)
at org.robolectric.res.RoutingResourceLoader.getValue(RoutingResourceLoader.java:31)
at org.robolectric.shadows.ShadowAssetManager.getAndResolve(ShadowAssetManager.java:263)
at org.robolectric.shadows.ShadowAssetManager.getResourceTextArray(ShadowAssetManager.java:100)
at org.robolectric.shadows.ShadowAssetManager.getResourceStringArray(ShadowAssetManager.java:74)
at android.content.res.AssetManager.getResourceStringArray(AssetManager.java)
at android.content.res.Resources.getStringArray(Resources.java:446)
at com.my.project.App.initialize(App.java:1657)
at com.my.project.App.onCreate(App.java:1603)
at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:146)
at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:387)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:227)
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:177)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
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.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)Caused by: java.lang.RuntimeException: ./../../volley/res/values is not a directory
at org.robolectric.res.DocumentLoader.load(DocumentLoader.java:39)
at org.robolectric.res.PackageResourceLoader.loadEverything(PackageResourceLoader.java:31)
at org.robolectric.res.PackageResourceLoader.doInitialize(PackageResourceLoader.java:19)
at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
at org.robolectric.res.OverlayResourceLoader.doInitialize(OverlayResourceLoader.java:22)
at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
at org.robolectric.res.XResourceLoader.getValue(XResourceLoader.java:53)
at org.robolectric.res.OverlayResourceLoader.getValue(OverlayResourceLoader.java:56)
at org.robolectric.res.RoutingResourceLoader.getValue(RoutingResourceLoader.java:31)
at org.robolectric.shadows.ShadowAssetManager.getAndResolve(ShadowAssetManager.java:263)
at org.robolectric.shadows.ShadowAssetManager.getResourceTextArray(ShadowAssetManager.java:100)
at org.robolectric.shadows.ShadowAssetManager.getResourceStringArray(ShadowAssetManager.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.robolectric.bytecode.ShadowWrangler$ShadowMethodPlan.run(ShadowWrangler.java:455)
at android.content.res.AssetManager.getResourceStringArray(AssetManager.java)
at android.content.res.Resources.$$robo$$Resources_fb43_getStringArray(Resources.java:446)
at android.content.res.Resources.getStringArray(Resources.java)
at com.my.project.App.initialize(App.java:1657)
at com.my.project.App.onCreate(App.java:1603)
at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:146)
at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:387)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:227)
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:177)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
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.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
... 1 more

If i manually create a res/values folder in the library project, the error
goes away


Reply to this email directly or view it on GitHubhttps://github.com//issues/641
.

Member

JakeWharton commented Aug 12, 2013

That may be the case. Volley is a jar, though. You can just drop the
compiled version into your libs/ folder.
On Aug 12, 2013 2:28 AM, "Maik Vlcek" notifications@github.com wrote:

I have setup an Android project, with a sub-tests project for unit testing.
I use the "org.robolectric.Config.properties" file to point Robolectric to
my correct AndroidManifest (manifest=../AndroidManifest.xml).

Now, when loading this and instantiating the Application object,
Robolectric tries to load all resources from my main project, as well as
related library projects. Some of them (like Android volley), don't provide
any resources, yet Robolectric seems eager to load them any way and quits
with an Exception

DEBUG: Loading resources for com.my.project from ./../res...DEBUG: Loading resources for com.viewpagerindicator from ./../../Android-ViewPagerIndicator/library/res...DEBUG: Loading resources for com.facebook.android from ./../../facebook-android-sdk-3.0.1/facebook/res...java.lang.RuntimeException: java.lang.RuntimeException: ./../../volley/res/values is not a directory
at org.robolectric.res.PackageResourceLoader.doInitialize(PackageResourceLoader.java:23)
at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
at org.robolectric.res.OverlayResourceLoader.doInitialize(OverlayResourceLoader.java:22)
at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
at org.robolectric.res.XResourceLoader.getValue(XResourceLoader.java:53)
at org.robolectric.res.OverlayResourceLoader.getValue(OverlayResourceLoader.java:56)
at org.robolectric.res.RoutingResourceLoader.getValue(RoutingResourceLoader.java:31)
at org.robolectric.shadows.ShadowAssetManager.getAndResolve(ShadowAssetManager.java:263)
at org.robolectric.shadows.ShadowAssetManager.getResourceTextArray(ShadowAssetManager.java:100)
at org.robolectric.shadows.ShadowAssetManager.getResourceStringArray(ShadowAssetManager.java:74)
at android.content.res.AssetManager.getResourceStringArray(AssetManager.java)
at android.content.res.Resources.getStringArray(Resources.java:446)
at com.my.project.App.initialize(App.java:1657)
at com.my.project.App.onCreate(App.java:1603)
at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:146)
at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:387)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:227)
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:177)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
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.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)Caused by: java.lang.RuntimeException: ./../../volley/res/values is not a directory
at org.robolectric.res.DocumentLoader.load(DocumentLoader.java:39)
at org.robolectric.res.PackageResourceLoader.loadEverything(PackageResourceLoader.java:31)
at org.robolectric.res.PackageResourceLoader.doInitialize(PackageResourceLoader.java:19)
at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
at org.robolectric.res.OverlayResourceLoader.doInitialize(OverlayResourceLoader.java:22)
at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
at org.robolectric.res.XResourceLoader.getValue(XResourceLoader.java:53)
at org.robolectric.res.OverlayResourceLoader.getValue(OverlayResourceLoader.java:56)
at org.robolectric.res.RoutingResourceLoader.getValue(RoutingResourceLoader.java:31)
at org.robolectric.shadows.ShadowAssetManager.getAndResolve(ShadowAssetManager.java:263)
at org.robolectric.shadows.ShadowAssetManager.getResourceTextArray(ShadowAssetManager.java:100)
at org.robolectric.shadows.ShadowAssetManager.getResourceStringArray(ShadowAssetManager.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.robolectric.bytecode.ShadowWrangler$ShadowMethodPlan.run(ShadowWrangler.java:455)
at android.content.res.AssetManager.getResourceStringArray(AssetManager.java)
at android.content.res.Resources.$$robo$$Resources_fb43_getStringArray(Resources.java:446)
at android.content.res.Resources.getStringArray(Resources.java)
at com.my.project.App.initialize(App.java:1657)
at com.my.project.App.onCreate(App.java:1603)
at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:146)
at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:387)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:227)
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:177)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
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.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
... 1 more

If i manually create a res/values folder in the library project, the error
goes away


Reply to this email directly or view it on GitHubhttps://github.com//issues/641
.

@coreydowning

This comment has been minimized.

Show comment
Hide comment
@coreydowning

coreydowning Oct 8, 2013

Collaborator

Sounds like the library is being included in a strange way. Please reopen if there is reason to believe this is a real Robolectric issue.

Collaborator

coreydowning commented Oct 8, 2013

Sounds like the library is being included in a strange way. Please reopen if there is reason to believe this is a real Robolectric issue.

@davcamer

This comment has been minimized.

Show comment
Hide comment
@davcamer

davcamer May 1, 2014

Ran in to this just now with an apklib we are building in-house. We use apklib so we can expose a couple of services in the AndroidManifest.xml, but they are purely background components, so there are no resources included.

Kept getting errors like the following, until I mkdir -p res/values in the apklib's root unpack directory:

Caused by: java.lang.RuntimeException: ./target/unpack/apklibs/mycorp_mycorp-stofor_apklib_10/res/res/values is not a directory
    at org.robolectric.res.DocumentLoader.load(DocumentLoader.java:39)
    at org.robolectric.res.PackageResourceLoader.loadEverything(PackageResourceLoader.java:42)
    at org.robolectric.res.PackageResourceLoader.doInitialize(PackageResourceLoader.java:26)
    at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
    at org.robolectric.res.OverlayResourceLoader.doInitialize(OverlayResourceLoader.java:22)
    at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
    at org.robolectric.res.XResourceLoader.getValue(XResourceLoader.java:53)
    at org.robolectric.res.OverlayResourceLoader.getValue(OverlayResourceLoader.java:56)
    at org.robolectric.res.RoutingResourceLoader.getValue(RoutingResourceLoader.java:31)
    at org.robolectric.shadows.ShadowAssetManager.getAndResolve(ShadowAssetManager.java:263)
    at org.robolectric.shadows.ShadowAssetManager.getAndResolve(ShadowAssetManager.java:259)
    at org.robolectric.shadows.ShadowAssetManager.getResourceText(ShadowAssetManager.java:62)
    at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.robolectric.bytecode.ShadowWrangler$ShadowMethodPlan.run(ShadowWrangler.java:456)

The maven-android-plugin docs do say that the res directory is "important", but when no resources are needed, it shouldn't need to exist, IMHO. But apparently, it does.
https://code.google.com/p/maven-android-plugin/wiki/ApkLib

We are using Robolectric 2.2 and maven-android-plugin 3.7.0.

davcamer commented May 1, 2014

Ran in to this just now with an apklib we are building in-house. We use apklib so we can expose a couple of services in the AndroidManifest.xml, but they are purely background components, so there are no resources included.

Kept getting errors like the following, until I mkdir -p res/values in the apklib's root unpack directory:

Caused by: java.lang.RuntimeException: ./target/unpack/apklibs/mycorp_mycorp-stofor_apklib_10/res/res/values is not a directory
    at org.robolectric.res.DocumentLoader.load(DocumentLoader.java:39)
    at org.robolectric.res.PackageResourceLoader.loadEverything(PackageResourceLoader.java:42)
    at org.robolectric.res.PackageResourceLoader.doInitialize(PackageResourceLoader.java:26)
    at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
    at org.robolectric.res.OverlayResourceLoader.doInitialize(OverlayResourceLoader.java:22)
    at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
    at org.robolectric.res.XResourceLoader.getValue(XResourceLoader.java:53)
    at org.robolectric.res.OverlayResourceLoader.getValue(OverlayResourceLoader.java:56)
    at org.robolectric.res.RoutingResourceLoader.getValue(RoutingResourceLoader.java:31)
    at org.robolectric.shadows.ShadowAssetManager.getAndResolve(ShadowAssetManager.java:263)
    at org.robolectric.shadows.ShadowAssetManager.getAndResolve(ShadowAssetManager.java:259)
    at org.robolectric.shadows.ShadowAssetManager.getResourceText(ShadowAssetManager.java:62)
    at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.robolectric.bytecode.ShadowWrangler$ShadowMethodPlan.run(ShadowWrangler.java:456)

The maven-android-plugin docs do say that the res directory is "important", but when no resources are needed, it shouldn't need to exist, IMHO. But apparently, it does.
https://code.google.com/p/maven-android-plugin/wiki/ApkLib

We are using Robolectric 2.2 and maven-android-plugin 3.7.0.

@jongerrish

This comment has been minimized.

Show comment
Hide comment
@jongerrish

jongerrish Aug 5, 2014

Contributor

I'm also seeing the same issue, we break our own app up into multiple small library components because it results in much faster builds. Some of these library components do not have resources (but may have a manifest file). Robolectric forces me to create dummy empty directories. It should not do this. I think this is a genuine issue.

Contributor

jongerrish commented Aug 5, 2014

I'm also seeing the same issue, we break our own app up into multiple small library components because it results in much faster builds. Some of these library components do not have resources (but may have a manifest file). Robolectric forces me to create dummy empty directories. It should not do this. I think this is a genuine issue.

@rcgonzalezf

This comment has been minimized.

Show comment
Hide comment
@rcgonzalezf

rcgonzalezf Feb 4, 2015

I'm having the same problem, I wonder if there is a Config property to point Roboelectric to my actual resources folder instead of creating dummy empty directories?

If not, I will say this is an issue.

Btw. I'm using Android Studio up to date ( 1.1 Beta 3 ) because of this other issue:
https://code.google.com/p/android/issues/detail?id=126013

I want to add support to my Lib, and my project structure is something like this:

project/
----MyLib/
--------src/
------------code.packages.classes
------------androidTest/
---------------------------java/
---------------------------------tests.packages.classes
----ApkUsingMyLib...
......

rcgonzalezf commented Feb 4, 2015

I'm having the same problem, I wonder if there is a Config property to point Roboelectric to my actual resources folder instead of creating dummy empty directories?

If not, I will say this is an issue.

Btw. I'm using Android Studio up to date ( 1.1 Beta 3 ) because of this other issue:
https://code.google.com/p/android/issues/detail?id=126013

I want to add support to my Lib, and my project structure is something like this:

project/
----MyLib/
--------src/
------------code.packages.classes
------------androidTest/
---------------------------java/
---------------------------------tests.packages.classes
----ApkUsingMyLib...
......

@chungyusu

This comment has been minimized.

Show comment
Hide comment
@chungyusu

chungyusu Sep 25, 2015

I think this is a configuration issue.
I am having the same issue since my resource folder is currently under 'src/main/res'.
However, after I tried to add the following arguments in my Android Studio Run Configuration under "VM options" field to let Robolectric knows where my resources files are placed, and the issue was resolved. I am not sure if there is any other better way to configure it.
Please note that my current build variant is DevDebug, so many intermediate paths are under Dev/debug

-ea -Dandroid.assets=build/intermediates/assets/Dev/debug -Dandroid.manifest=build/intermediates/manifests/full/Dev/debug/AndroidManifest.xml -Dandroid.resources=build/intermediates/res/Dev/debug

chungyusu commented Sep 25, 2015

I think this is a configuration issue.
I am having the same issue since my resource folder is currently under 'src/main/res'.
However, after I tried to add the following arguments in my Android Studio Run Configuration under "VM options" field to let Robolectric knows where my resources files are placed, and the issue was resolved. I am not sure if there is any other better way to configure it.
Please note that my current build variant is DevDebug, so many intermediate paths are under Dev/debug

-ea -Dandroid.assets=build/intermediates/assets/Dev/debug -Dandroid.manifest=build/intermediates/manifests/full/Dev/debug/AndroidManifest.xml -Dandroid.resources=build/intermediates/res/Dev/debug

@chungyusu

This comment has been minimized.

Show comment
Hide comment
@chungyusu

chungyusu Sep 25, 2015

Another tips is try to use "@RunWith(RobolectricGradleTestRunner.class)" instead of "@RunWith(RobolectricTestRunner.class)", that might also help.

chungyusu commented Sep 25, 2015

Another tips is try to use "@RunWith(RobolectricGradleTestRunner.class)" instead of "@RunWith(RobolectricTestRunner.class)", that might also help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment