Search code examples
androidandroid-productflavors

flavour : override package name


I had a project with this package name : applicationId 'com.safa.auditzanjan' Now I have created a flavour into other same project and I have added those project into this project. this new package name's project is:applicationId "com.safa.auditkhoramabad". how could I set older package Name to this flavour?Thats mean I want to do override com.safa.auditkhoramabad for my new flavour to com.safa.auditzanjan?

***EDIT***********

this is my Independent gradle config project:

    defaultConfig {
    applicationId 'com.safa.auditzanjan'
    minSdkVersion 15
    targetSdkVersion 25
    multiDexEnabled true
    versionCode 56
    versionName '1.8.56'
}
dexOptions {
    jumboMode = true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug {
        applicationIdSuffix '.debug'
        versionNameSuffix '-debug'
    }
}
productFlavors {
    main {
        signingConfig signingConfigs.SigningConfig1
    }
    ts {
        signingConfig signingConfigs.SigningConfig1
        applicationIdSuffix ".ts"
        versionNameSuffix "-ts"
    }
}

this is flavour gradle config:

        zanjan {
        applicationId 'com.safa.auditzanjan'
        signingConfig signingConfigs.SigningConfig1
        applicationIdSuffix ".zanjan"
        versionNameSuffix "-zanjan"
        versionCode 56
        versionName '1.8.56'
        resValue( "string", "app_name", "ممیزی زنجان")
    }

Solution

  • You should be able to do something like following

    productFlavors {
    
        flavor1 {
            applicationId "com.safa.auditzanjan"
    
        }
    
    
        flavor2 {
            applicationId "com.safa.auditkhoramabad"
    
        }