Robolectric says "AndroidManifest.xml not found"
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
}
}
}
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.
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.