Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Robolectric cannot find AndroidManifest.xml

This test originally ran fine. Checked out a new branch several days later (with commits from many other developers) and it no longer works.

Test class in the mylibrary library module:

import com.company.mylibrary.BuildConfig;

@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, manifest = "src/main/AndroidManifest.xml", sdk = 21)
public class MyTest {

I have also tried:

@Config(constants = BuildConfig.class, sdk = 21)
@Config(constants = BuildConfig.class, manifest = Config.NONE, sdk = 21)

In the library module's build.gradle

dependencies {
    .
    .
    testCompile 'org.robolectric:robolectric:3.0'

Error message when running inside AS is: java.lang.RuntimeException: build/intermediates/manifests/full/debug/AndroidManifest.xml not found or not a file; it should point to your project's AndroidManifest.xml

Error message when running from command line is: com.company.mylibrary.framework1.feature1.MyTest > testMethod STANDARD_ERROR java.lang.RuntimeException: build/intermediates/manifests/full/debug/AndroidManifest.xml not found or not a file; it should point to your project's AndroidManifest.xml

A) Don't know why it is looking there for the manifest B) That file/directory does not exist C) src/main/AndroidManifest.xml does exist

Things I have tried: - deleted the build directory in that library module - restarted Android Studio - Build/Clean - Build/Rebuild Project - run the test (both inside AS and from command line) - and tried different versions of the @Config notation

Seems to be in a wonky state that I cannot clear.

I am working on a MacBook Pro. Android Studio 2.0 beta5

like image 356
Steven Stamps Avatar asked Feb 08 '23 15:02

Steven Stamps


1 Answers

You need to set the working directory within the test's run configuration to the module directory.enter image description here

like image 149
UmAnusorn Avatar answered Feb 15 '23 09:02

UmAnusorn