Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AndroidManifest.xml for Gradle instrumentTest

Is there a way to specify an additional AndroidManifest.xml file for a gradle test aplication? I need it to specify additional permissions and activities for my unit tests.

UPD: I've tried to add instrumnetTest section in the build.gradle file, but it didn't help and I still get Unable to resolve activity for: Intent error

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }
    instrumentTest {
        manifest.srcFile 'src/instrumentTest/AndroidManifest.xml'
        java.srcDir 'src/instrumentTest/Java'
    }
}
like image 863
Ivan Gromov Avatar asked Oct 23 '13 15:10

Ivan Gromov


1 Answers

You can specify an special AndroidManifest.xml for Android Tests (formerly called Instrument Tests) if you are able to use the 0.13.0 (or later) release of the Android Gradle Plugin.

Simply put the file at src/androidTest/AndroidManifest.xml - the manifest merger will take care of the file when you run the gradle test task.

There's an example in the official documentation "gradle-samples-0.13.zip\gradle-samples-0.13\androidManifestInTest" - as one can see there's no special configuration needed to have the test manifest included.

like image 72
Briareos386 Avatar answered Sep 20 '22 02:09

Briareos386