'Resources not found' when using Roboguice

33 views
Skip to first unread message

Ryan Bateman

unread,
May 20, 2013, 6:27:09 AM5/20/13
to robol...@googlegroups.com
Hi all,

I've been using Robolectric for a while, but not when as part of a Maven-built project.  I am now, using the latest build (including, now, the official 2.0 release - congratulations on shipping!), and running into a error when trying to test using Roboguice-injected classes that contain, themselves, an injected resource (i.e. I inject an Activity which contains an injected resource).  The end result is a ResourceNotFoundException.  
I think it is to do with my project's structure.  In effect, my tests (instrument and unit) are a separate Maven module (albeit one with the same parent pom.)  I can reference the latest build of the app within the test project simply using a Maven dependency, but either only as a jar or an apk i.e. 

<dependency>
<groupId>com.bargainguy.app</groupId>
<artifactId>bargainguy-android</artifactId>
<type>jar</type>
<version>0.1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.bargainguy.app</groupId>
<artifactId>bargainguy-android</artifactId>
<type>apk</type>
<version>0.1</version>
<scope>provided</scope>
</dependency>

However, this won't include the resources. So I'm left wondering whether there's a way for me to reference the resources from within this separate test project so that injected classes from my main application can still, within themselves, contain injected resources.  
(If it's any help, you can reproduce the app structure I'm using using the de.akquinet android maven archetype listed here - specifically, the final android-release type.)
I appreciate this may not be a robolectric issues - that it may be more of a maven question - but I figured that you guys may have some experience with type of app structure. Any help or thoughts greatly appreciated.

Ryan

Ryan Bateman

unread,
May 20, 2013, 8:35:21 AM5/20/13
to robol...@googlegroups.com
Ah, nevermind.  I've abandoned that project structure in favour of a single project with test subdirectories.  Akquinet's own solution to this is seemingly to duplicate generated R files using a Maven plugin, which seems somewhat ridiculous.  
Reply all
Reply to author
Forward
0 new messages