Development issue/problem:
If I try to make Robolectric RC3 work in Android Studio, I get
Reason: java.lang.RuntimeException: build/intermediates/bundles/debug/AndroidManifest.xml file not found or not found; it should be on your project’s org.robolectric.manifest.AndroidManifest.xml
.validate(AndroidManifest.java:120)
on org.robolectric.manifest.getResourcePath(AndroidManifest.java:469)
on org.robolectric.manifest.getIncludedResourcePaths(AndroidManifest.java:475)
on org.robolectric.RobolectricTestRunner.createAppResourceLoader(RobolectricTestRunner.java:479)
on org.robolectric.RobolectricTestRunner.getAppResourceLoader(RobolectricTestRunner.java:471)
on org.robolectric.internal.ParallelUniverse.setUpApplicationState (ParallelUniverse.java:73)
on org.robolectric.RobolectricTestRunner.setUpApplicationState (RobolectricTestRunner.java:421)
on org.robolectric.RobolectricTestRunner$2.parallel (RobolectricTestRunner.java:234)
I tried.
@Config(manifest = app/src/main/AndroidManifest.xml, constants = BuildConfig.class, sdk=21)
And I tried to put the manifest security system in my Test Runner, but it didn’t work. In the Dateisystem, I believe that the Manifesto in
./app/build/manifest/complete/debug/AndroidManifest.xml
an der falschen Stelle, wo der Robollectric nach ihm sucht.
One point in the manifesto was simply ignored, and then a unique resource problem arose: the App or Robolestrice could not find the raw material that spoiled my App.
Es steht in meiner Build-Datei:
sourceSet {main {java.srcDirs = [ src/main/java’]resources.srcDirs = [ src/main/res’]]test {java.srcDirs = [ src/main/java’]resources.srcDirs = [ src/main/res srcDirs = [ src/test/java’, ‘src/main/java’]resources.srcDirs = [ src/test/res’, ‘src/main/res’]}.
How do you explain Robolestry, where the manifesto is to be found and, what is even more important, where such a thing can be done in terms of resources?
Editing:
I have checked out the Robolectric fromithub, built it and installed it in my .m2-Repo premises. The Gradle file now refers to the local version of SNAPSHOT and I made sure that Gradle doesn’t get a new version of the remote repo. Then I copied RobolectricGradleTestRunner to my project, changing the lines where the file locations were defined: it had no module name. Now it’s working.
How can I solve this problem?
Solution 1:
I assume you’re trying to test with JUnit. You can try two different things:
- Create a custom TestRunner class as shown here. See the CustomTestRunner section where you essentially create a TestRunner that knows the right manifesto. Specify your tests with the @Config annotation to make them work with your test runner.
- (My favorite selection) Go to JUnit configuration, start > Change settings. Write down the text box in the workbook. Add /app (for OSX and Linux) or application (Windows) to the path written in the text box. Try it again, it should work.
Solution 2:
Same problem with Android Studio. I solved this problem by changing the configuration of Unit 4. You can keep an eye on her.
Android studios.
- Change Configuration
- In June, you must change the workbook to $MODULE_DIR$.
The bottom line is $MODULE_DIR$.
You can see the following screenshot. Thank you so much!
Solution 3:
I’ve encountered the same mistakes, we’ve used different flavours and
manufacturers, so there are steps to make it work:
- Setting up the Android Studio Trial
On Windows, you must also set the working directory to $MODULE_DIR$. That should say http://robolectric.org/getting-started/.
- The unit test shall be annotated as follows:
@RunMet(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21, manifest = src/main/AndroidManifest.xml, packageName = com.example.yourproject)
public class SomeFragmentTest {
Solution 4:
If you still get this error with Android Studio 3.0, make sure your scale configuration has these settings:
android {…testOptions {unitTests {includeAndroidResources = true}}}}
Solution No 5:
Note that intellij 16 EAP has a bug with this $MODULE_DIR$ variable (it points to the wrong place), which causes an error when testing with this exception. See https://youtrack.jetbrains.com/issue/IDEA-149802#tab=History. To be corrected by mid-January 2016.
Solution No 6:
You can ask the same question here: https://github.com/robolectric/robolectric/issues/1648
You have to mention it in your test code:
@Config(manifest = src/main/AndroidManifest.xml, emulateSdk = 18)
This tells the robot technician where your declaration file is located. This should work as long as you don’t change the values in the directory.
Also try to use a template that is available on the internet, everything is configured there, you don’t have to change the values of the folders. You can get it here: https://github.com/robolectric/deckard-gradle
Edit: I think the exception is under build/intermediates/bundles/debug/AndroidManifest.xml, but you say the file is under app/build/intermediates/manifests/full/debug/AndroidManifest.xml, I think the two locations are different. Make sure you have an xml file on build/intermediates/bundles/debug/AndroidManifest.xml.
Solution No 7:
That’s right @Christina. I also have exactly the same problem. And it is a fact that the building process is not at all about creating a package folder for intermediaries. And the modified robot runner didn’t work either. A customer-specific cursor I
is used here. I haven’t found the solution yet, but it seems that the problem is related to the version of the build tool.
Solution No 8:
I got this error after updating AndroidStudio to version 2.3.3, and my gradle plugin was also updated.
Проблема решена путем установки рабочего каталога в $MODULE_DIR$, а также обновления robolectric зависимостей от testCompile ‘org.robolectric:robolectric:3.0’ до testCompile ‘org.robolectric:robolectric:3.4.2’.
Special featuresбратите внимание, что настройка рабочего каталога при старой версии робототехники не разрешит его.
Решение № 9:
Пожалуйста, ознакомьтесь с нижеприведенными шагами, которые помогут решить все проблемы.
Шаг 1: используйте в зависимостях
testImplementationorg.robolectric: robolectric:4.0 в app.gradle
этап 2 : In the app.gradle indoor android use below
testOptions {
unitTests {
includeAndroidResources = true
}
}.
Step 3: paste into gradle.properties below
enableUnitTestBinaryResources=true
It’s working!
Good luck!
Related Tags:
robolectric androidx,robolectric-gradle version,robolectric api 29,robolectrictestrunner,robolectric config,robolectric java 8,called loadfrompath(/system/framework/framework-res apk true); mode=binary sdk=28,robolectric test android