xml中的摇篮instrumentTest

xml中的摇篮instrumentTest

本文介绍了AndroidManifest.xml中的摇篮instrumentTest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来指定一个额外的的Andr​​oidManifest.xml 文件的摇篮测试aplication?我需要它指定我的单元测试额外的权限和活动。

UPD:我试图加入 instrumnetTest build.gradle 文件部分,但它并没有帮助,我仍然获得无法解析的活动:意向错误

  sourceSets {
    主要 {
        manifest.srcFile的Andr​​oidManifest.xml
        java.srcDirs = ['src'中]
        resources.srcDirs = ['src'中]
        aidl.srcDirs = ['src'中]
        renderscript.srcDirs = ['src'中]
        res.srcDirs = ['水库']
        assets.srcDirs = ['资产']
    }
    instrumentTest {
        manifest.srcFileSRC / instrumentTest / AndroidManifest.xml中
        java.srcDirSRC / instrumentTest / Java的'
    }
}
 

解决方案

您可以指定一个特殊的的Andr​​oidManifest.xml 为Android测试(以前称为仪器测试),如果你是可以使用 0.13.0 (或更高版本)发布了Android摇篮插件的。

简而言之文件的的src / androidTest / AndroidManifest.xml中 - 清单合并将采取文件的照顾,当你运行的摇篮测试任务。

有没有在正式文件<一个例子href="https://docs.google.com/viewer?a=v&pid=sites&srcid=YW5kcm9pZC5jb218dG9vbHN8Z3g6M2U5ZGUzNTU3M2M3NDA0ZA">"gradle-samples-0.13.zip\gradle-samples-0.13\androidManifestInTest" - 作为一个可以看到有需要有测试清单包含任何特殊配置

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'
    }
}
解决方案

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.

这篇关于AndroidManifest.xml中的摇篮instrumentTest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 03:59