Robolectric Says "androidmanifest.xml Not Found"
Solution 1:
I'm assuming you're trying to run the tests with JUnit. You can try two different things:
- Create a Custom TestRunner class, as shown here. Check the CustomTestRunner section, where you basically create a TestRunner that actually knows the right manifest to use. Specify your tests for them to run with your test runner, with the
@Config
annotation. - (My preferred choice) Go the your JUnit configuration, Run > Edit Configurations. Notice the 'Working Directory' textbox. Append
/app
(for OSX and Linux) or\app
(Windows), to the path written in the textbox. Try running again and it should work.
Solution 2:
Same problem on Android Studio. I've solved this problem to edit the configuration of Unit4. you can follow these things.
On Android Studio.
- Edit Configurations
- In Junit, you have to change the working directory to $MODULE_DIR$.
The important thing is $MODULE_DIR$.
you can reference the following screenshot. thanks.
Solution 3:
In case you are still getting this error with Android Studio 3.0, please be sure that your gradle configuration has these parameters:
android {
...
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
Solution 4:
I have faced same errors, We used several flavors and buildtypes So, there are steps to make it working:
- Android studio tests run configuration
You have to set working directory to $MODULE_DIR$ in Windows too. http://robolectric.org/getting-started/ should say that.
Unit test should be annotated like this:
@RunWith(RobolectricTestRunner.class) @Config(constants = BuildConfig.class, sdk = 21, manifest = "src/main/AndroidManifest.xml", packageName = "com.example.yourproject") public class SomeFragmentTest {
Solution 5:
Note that intellij 16 EAP has a bug around this $MODULE_DIR$ variable (it's pointing to the wrong place), causing the tests to fail with this exception. See https://youtrack.jetbrains.com/issue/IDEA-149802#tab=History. Should get fixed mid Jan 2016.
Post a Comment for "Robolectric Says "androidmanifest.xml Not Found""