我有一个具有2种风格的库模块。我想要的是,风味仅包含模块,而不包含在应用程序本身中,但是出现依赖项问题。 这是我的模块“ testlib”的gradle文件:
android {
compileSdkVersion 29
flavorDimensions "exampleflav"
publishNonDefault true
productFlavors {
flav1 {}
flav2 {}
}
应用gradle文件:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.prose.flavortest"
minSdkVersion 22
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation project(path:':testlib', configuration: 'flav1Release')
}
当我尝试同步时,出现以下错误: ...
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :testlib.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve project :testlib.
Show Details
Affected Modules: app
...
我知道添加后它将起作用
flavorDimensions "exampleflav"
publishNonDefault true
productFlavors {
flav1 {}
flav2 {}
}
到我的应用gradle文件,但这正是我所不想要的。是否有机会仅在没有将它们添加到应用程序本身的情况下将它们添加到库中?