I'm trying to hide my fabric API key from source control by putting the key in an un-tracked string resource XML file. But for some reason, fabric is not accepting the key vie @string/FABRIC_API_KEY
reference in the manifest.
The XML file is as follows -
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="NASA_API_KEY">abcd</string>
<string name="FABRIC_API_KEY">xyz</string>
</resources>
The reference in the manifest -
<meta-data
android:name="io.fabric.ApiKey"
android:text="@string/FABRIC_API_KEY" />
And, here is the error I get on an attempt to build -
Error:Execution failed for task ':app:fabricGenerateResourcesDebug'. Crashlytics Developer Tools error.
I have tried accessing the API key via BuildConfig
and it still does not work.
According to Fabric,
You should stop adding this key field in AndroidManifest.xml. Instead you should add it in fabric.properties.
Basically fabric library will automatically merge this key later in your merged AndroidManifest.xml.
REF : https://docs.fabric.io/android/fabric/settings/working-in-teams.html#android-projects
Hope this helps.
In build.gradle
add manifestPlaceholders
:
defaultConfig {
manifestPlaceholders = [
FABRIC_API_KEY:"Your Key"
]
}
Use it in AndroidManifest.xml
like
<meta-data
android:name="io.fabric.ApiKey"
android:value="${FABRIC_API_KEY}"
/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With