Supporting multiple app variants

If you want to use different Hansel App Id for different build types or flavors, you'll have to use module's build.gradle file for it. For example if you want to have different Hansel App Id for debug and release build types, you can update your configuration to look like the one below:

buildTypes{
    debug{
        resValue 'string', "hansel_app_id", "<DEBUG_APP_ID>"
        resValue 'string', "hansel_app_key", "<DEBUG_APP_KEY>"
    }
    release{
        resValue 'string', "hansel_app_id", "<RELEASE_APP_ID>"
        resValue 'string', "hansel_app_key", "<RELEASE_APP_KEY>"
    }
}

If you want to have different Hansel App Id for different flavors, you can update your configuration to look like the one below:

productFlavors {
stage {
resValue 'string', "hansel_app_id", "<STAGE_APP_ID>"
resValue 'string', "hansel_app_key", "<STAGE_APP_KEY>"
}
prod {
resValue 'string', "hansel_app_id", "<PROD_APP_ID>"
resValue 'string', "hansel_app_key", "<PROD_APP_KEY>"
}
}

Now modify your AndroidManifest.xml to the following:

<meta-data
android:name="HANSEL_APP_ID"
android:value="@string/hansel_app_id" />
<meta-data
android:name="HANSEL_APP_KEY"
android:value="@string/hansel_app_key" />

 

 

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.