In my AndroidManifest.xml file I have the following meta-data tag which should be populated dynamically:
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="${FACEBOOK_APP_ID}"/>
My gradle file looks like this:
manifestPlaceholders = [
GOOGLE_PROJECT_ID: "A888844613784",
FACEBOOK_APP_ID: "888570042741264"
]
After "Build & Assemble" the FACEBOOK_APP_ID in the manifest file looks like this:
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="1481023616.000000" />
Unfortunately this is not a String, but a float value. That's not correct or what I want.
I know there is another way to define the FACEBOOK_APP_ID
in the string.xml
file. But since I have lots of flavors it would be nice and easy to maintain if we put all flavors-related parameters in the build.gradle
file instead of the strings.xml
files.
Does anyone know how to avoid the string to float conversion?
You can use the following code to add a String value to your string resources from a build.gradle file:
resValue 'string', 'FACEBOOK_APP_ID', 'facebook_application_id'
But I'm not sure if the AndroidManifest.xml file does not support flavor specific strings (I can remember you will get a warning if you try, but I'm not sure).
You could also try to add a null-terminator to your FACEBOOK_APP_ID manifestPlaceholder as suggested in this answer:
FACEBOOK_APP_ID: "888570042741264\0"
Edit:
The code null-terminator method seems not to be working when used directly from the build.gradle file, it does however work when using the null-terminator inside the AndroidManifest.xml
file:
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="${FACEBOOK_APP_ID}\0"/>