Unable to build feature modules in a multi-flavor app

前端 未结 3 1543
清酒与你
清酒与你 2021-01-18 11:00

I am using Gradle 4.4 with Gradle-Android plugin 3.1.1 on Android Studio 3.1.1.

I have 2 flavors \'a\' and \'b\' and I am unable to build my project due to the follo

3条回答
  •  青春惊慌失措
    2021-01-18 11:39

    It seems you didn't specify difference in the names of a and b packages. Below is my working implementation of flavor feature for API 25 and com.android.tools.build:gradle:2.3.1 in the app level build.gradle of AS 2.3.3:

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 25
        buildToolsVersion "25.0.3"
    
        defaultConfig {
            applicationId "com.example"
            minSdkVersion 14
            targetSdkVersion 25
            versionCode 1
            versionName "1.00"
        }
    
        signingConfigs {
            config {
                storeFile file(STORE_PATH)
                keyAlias KEY_ALIAS
                keyPassword KEY_PASSWORD
                storePassword KEYSTORE_PASSWORD
            }
        }
    
        productFlavors {
            nosync {
                applicationIdSuffix ".nosync"
                versionNameSuffix '-nosync'
                signingConfig signingConfigs.config
            }
            sync {
                signingConfig signingConfigs.config
            }
        }
    
        buildTypes {
            release {
                debuggable false
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                signingConfig signingConfigs.config
            }
            debug {
                debuggable true
                signingConfig signingConfigs.config
            }
        }
    
    dependencies {
        ...
    }
    

    Take a look on difference

    applicationIdSuffix ".nosync"
    versionNameSuffix '-nosync'
    

    between nosync and sync flavors. It will change the package name of nosync apk.

提交回复
热议问题