Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKevin Eaton
9,527 PointsRobolectric Fails and Manifest
When trying to test with Robolectric in the video, I run the test and get the following:
WARNING: No manifest file found at ./AndroidManifest.xml.Falling back to the Android OS resources only. To remove this warning, annotate your test class with @Config(manifest=Config.NONE).
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
When I specify the manifest file directly, such as:
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP, manifest = "src/main/AndroidManifest.xml")
I get:
java.lang.NullPointerException at org.robolectric.shadows.ShadowAssetManager$OverlayedStyle.equals(ShadowAssetManager.java:336) at org.robolectric.shadows.ShadowAssetManager.applyThemeStyle(ShadowAssetManager.java:309) at org.robolectric.shadows.ShadowResources$ShadowTheme.applyStyle(ShadowResources.java:246) at android.content.res.Resources$Theme.applyStyle(Resources.java) at android.view.ContextThemeWrapper.onApplyThemeResource(ContextThemeWrapper.java:128) at android.app.Activity.onApplyThemeResource(Activity.java:3661) at android.view.ContextThemeWrapper.initializeTheme(ContextThemeWrapper.java:140) at android.view.ContextThemeWrapper.setTheme(ContextThemeWrapper.java:85) at android.support.v7.app.AppCompatActivity.setTheme(AppCompatActivity.java:86) at org.robolectric.shadows.ShadowActivity.setThemeFromManifest(ShadowActivity.java:94) ....
My gradle file includes the following:
testCompile 'org.robolectric:robolectric:3.1'
Fabio Antunes
Courses Plus Student 10,684 PointsFabio Antunes
Courses Plus Student 10,684 PointsThere are a few things you could try; The first one is checking your JUnit Run Configurations and set the Working Directory to $MODULE_DIR$
Since it's been two years, there are newer versions of the framework Roboletric and also Android Studio. Therefore, for anyone else running into similar issues, I would recommend having a look at the robolectric getting started page. http://robolectric.org/getting-started/