android – How to use different package names between flavors?-ThrowExceptions

Exception or error:

I’m trying to create a single project with 2 flavors: free and pro (versions).

My app is already in PlayStore with different packages (E.g.: com.example.appfree and

This is my build.gradle:

defaultConfig {
   applicationId "com.example.appfree"
   lite {
       applicationIdSuffix 'lite'

   pro {


And this is my manifest file:

<?xml version="1.0" encoding="utf-8"?>


                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />

        <activity android:name=".MainActivity"/>



I tried to upload a build apk for free and pro flavors. Pro flavor is ok, but free flavor isnt accepted by Google, because the package is incorrect. How can I solve this?

====== Solved: ======
applicationIdSuffix only works with buildTypes.

How to solve:

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.


apply plugin: ''
android {
    compileSdkVersion 19
    buildToolsVersion "19.1"
    defaultConfig {
        applicationId ""
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"


productFlavors {
    pro {
        applicationId = ""
    free {
        applicationId = ""

buildTypes {
    debug {
        applicationIdSuffix ".debug"

from Android Studio Project Site – ApplicationId versus PackageName


flavorDimensions "version"
productFlavors {
    demo {
        // Assigns this product flavor to the "version" flavor dimension.
        // This property is optional if you are using only one dimension.
        dimension "version"
        applicationIdSuffix ".demo"
        versionNameSuffix "-demo"
    full {
        dimension "version"
        applicationIdSuffix ".full"
        versionNameSuffix "-full"

Leave a Reply

Your email address will not be published. Required fields are marked *