我尝试(在示例应用程序中)让一个“ :test ”模块测试主模块“ :app ”和“ :dynamicfeature ”模块。为此,我使用“com.android.test”gradle 插件。
我的“ :app ”模块运行良好。它从我的“ :dynamicmodule ”中实例化了一个基本视图。
不幸的是,我的“ :test ”模块在“processDebugManifest”期间失败了。
错误是:
无法计算任务 ':test:processDebugManifest' 属性 'testedApplicationId' 的值。
集合有不止一个元素。
事实上,似乎测试模块不接受实现“com.android.application”模块和“com.android.dynamic-feature”模块
任何想法?谢谢
这是我的 build.gradle (:test)
plugins {
id 'com.android.test'
id 'kotlin-android'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
publishNonDefault true
defaultConfig {
minSdkVersion 21
targetSdkVersion 30
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
targetProjectPath ':app'
targetVariant 'debug'
}
dependencies {
implementation project(":app")
implementation project(":dynamicfeature")
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.test.ext:junit:1.1.2'
implementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'androidx.test:core:1.0.0'}
这是我的 build.gradle (:app)
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.sample.app"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
dynamicFeatures = [':dynamicfeature']
}
dependencies {
implementation "com.google.android.play:core:1.8.3"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
这是我的 build.gradle (:dynamicfeature)
plugins {
id 'com.android.dynamic-feature'
id 'kotlin-android'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
publishNonDefault true
applicationId "com.sample.module"
minSdkVersion 21
targetSdkVersion 30
}
buildTypes {
release {
minifyEnabled false
}
debug{
}
}
}
dependencies {
implementation project(":app")
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
testImplementation 'junit:junit:4.+'
}