androidflutterflutter-build

Having multiple builds of same flutter app on android device


For debugging purposes - I want to have multiple builds of my flutter app. One - should be from google play and few others like "App Name - Dev" Or "App Name - STG". I tried to use flavors and modifying android:label="@string/app_name" however I cant install new build of app - android complains with following message - app not installed as package conflicts with an existing package

So how do I have multiple builds of same app on my device?


Solution

  • In device or playstore , app is identified by bundle id and as per error it looks like you are trying to install app with same bundle id which is already installed on device . To make same app different, you need to make bundle id different which you can achieve by flavours . Kindly consider below mentioned code

    android {
        defaultConfig {
            applicationId "com.example.myapp"
        }
        productFlavors {
            free {
                applicationIdSuffix ".free"
            }
            pro {
                applicationIdSuffix ".pro"
            }
        }
    }
    

    here we have two flavours

    1. free
    2. pro

    now both will have different bundle id as applicationIdSuffix will append string at the end of original bundle id

    So for free flavour , it will be com.example.myapp.free and for pro flavour , it will be com.example.myapp.pro

    For more details , you can check this link

    https://developer.android.com/build/build-variants#groovy