Is it possible to programmatically set the app key for Localytics? From the integration guide (https://support.localytics.com/Android_SDK_integration), it seems like you must set it in the Manifest file as meta-data.
<meta-data android:name="LOCALYTICS_APP_KEY" android:value="APP KEY FROM STEP 2"/>
From the following post, it also seems like it's impossible to dynamically set Android meta-data. How to add metadata dynamically (Not in manifest but inside code)?
I'd like to be able to set the app key dynamically based on Gradle buildType so I can have a release app key and a debug app key.
You can use manifest merging to support different app keys for your build types (e.g. debug versus release) or your product flavors (e.g. free versus paid).
To support different app keys for your builds types:
src/debug/AndroidManifest.xml
and src/release/AndroidManifest.xml
.src/main/AndroidManifest.xml
.src/debug/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app" >
<application>
<meta-data
android:name="LOCALYTICS_APP_KEY"
android:value="DEBUG_APP_KEY" />
</application>
</manifest>
src/release/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app" >
<application>
<meta-data
android:name="LOCALYTICS_APP_KEY"
android:value="RELEASE_APP_KEY" />
</application>
</manifest>
For different app keys based on your product flavors, just replace debug
and release
above with your product flavor names.