Android 仅模块库中的ProductFlavor

Android 仅模块库中的ProductFlavor,android,gradle,kotlin,android-productflavors,Android,Gradle,Kotlin,Android Productflavors,我有一个库模块,有两种风格。我想要的是,这些风格只包含模块,而不包含在应用程序本身中,但我会遇到依赖性问题。 这是我的模块“testlib”的gradle文件: 应用程序梯度文件: apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 29 def

我有一个库模块,有两种风格。我想要的是,这些风格只包含模块,而不包含在应用程序本身中,但我会遇到依赖性问题。 这是我的模块“testlib”的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')
}
尝试同步时,出现以下错误:

我知道当我添加

flavorDimensions "exampleflav"
publishNonDefault true
productFlavors {
    flav1 {}
    flav2 {}
}
但这正是我不想要的。有没有可能只在库中添加口味而不将其添加到应用程序本身

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 {}
}