How to use different package names between flavors?

With the new Android Gradle build system, you can easily build multiple different versions of your app; for example, you can build both a “free” version and a “pro” version of your app (using flavors), and these should have different packages in the Google Play store such that they can be installed and purchased separately, both installed at the same time, and so on. Similarly, you may also build both “debug” and “alpha” and “beta” versions of your app (using build types) and these can also similarly contribute to unique package names.

app/build.gradle:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 19
    buildToolsVersion "19.1"
    defaultConfig {
        applicationId "com.example.my.app"
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
...

app/build.gradle:

productFlavors {
    pro {
        applicationId = "com.example.my.pkg.pro"
    }
    free {
        applicationId = "com.example.my.pkg.free"
    }
}

buildTypes {
    debug {
        applicationIdSuffix ".debug"
    }
}
....

from Android Studio Project Site – ApplicationId versus PackageName

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)