问题描述
我尝试(在示例应用程序中)使用一个“:test”模块来测试主模块“:app”和“:dynamicfeature” ”模块。 为此,我使用“com.android.test”gradle 插件。
我的“:app”模块运行良好。它从我的“:dynamicmodule”中实例化了一个基本视图。
不幸的是,我的“:test”模块在“processDebugManifest”期间失败。
错误是:
无法计算任务“:test:processDebugManifest”属性“testedApplicationId”的值。
集合有多个元素。
实际上似乎测试模块不接受实现“com.android.application”模块AND“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.+'
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)