hb0*_*hb0 6 android android-testing android-studio gradle-android-test-plugi android-gradle-3.0
我想做的事和问题
我将 Android Studio 和 Android Gradle 插件更新为 3.0.1,将 Gradle Wrapper 更新为 4.1,并且可以通过 IDE 在设备上以发行版本构建和部署我的 Android Gradle 项目。
但是,会显示以下“Gradle Sync”警告消息:
警告:模块“库”选择了变体“发布”,但模块[“集成测试”]依赖于变体“调试”
这里的问题是,使用“com.android.test”插件的集成测试模块没有“发布”变体。
如果我只是尝试将发布构建类型 ( buildTypes { release {} }) 添加到 :integration-test 模块,我会收到:
错误:VariantInputs 初始化时没有合并清单报告:DEFAULT
项目详情(简体)
该项目包括:
设置.gradle
include :library
include :app
include :integration-test
Run Code Online (Sandbox Code Playgroud)
应用程序/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
publishNonDefault true
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
applicationId "xxxxx"
testInstrumentationRunner rootProject.ext.testInstrumentationRunner
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
signingConfigs {
release {
keyAlias 'xxxx'
}
}
buildTypes {
debug {
testCoverageEnabled = true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
// This is needed by the integration-test module (i.e. com.android.test : integration test)
// in order for targetVariant to work without a flavor
publishNonDefault true
testOptions {
unitTests {
// Required so that logging methods do not throw not mocked exceptions in junit tests.
returnDefaultValues = true
}
}
compileOptions {
sourceCompatibility rootProject.ext.sourceCompatibility
targetCompatibility rootProject.ext.targetCompatibility
}
}
dependencies {
// Local dependencies
compile project(':library')
// i cleaned up all the other dependencies as they wouldn't help here
}
Run Code Online (Sandbox Code Playgroud)
问题
有没有人使用 com.android.test 插件获得(集成)测试模块来与Android Gradle Plugin 3.0.1一起运行,而不会出现“无发布变体”错误?如果是这样,我怎样才能避免这个错误,或者我怎样才能将这样的发布变体添加到基于 android 测试插件的模块中(如果这有意义的话)?
我也得到了
VariantInputs 已初始化,没有合并清单报告:DEFAULT。
然后我完全按照https://github.com/googlesamples/android-testing-templates/tree/master/AndroidTestingBlueprint中概述的内容进行操作
当我从测试模块的 Gradle 文件中的“buildTypes”块中删除releasebuildType时,错误消失了。由此:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Run Code Online (Sandbox Code Playgroud)
到
buildTypes {
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9930 次 |
| 最近记录: |