Fabric/Crashlytics Android adding string resource for Apikey causes Crashlytics Developer Tools Error
Asked Answered
A

2

9

In my android app, I added a the following string resource in the

AndroidManifest.xml

 <meta-data
  android:name="io.fabric.ApiKey"
 android:value="@string/fabric_key" />

and in strings.xml

 <string name="fabric_key">XXXXXXXXXXXXXXXXXXXXXXXX</string>

when I try to build the project I get the following error:

Error:Execution failed for task ':app:fabricGenerateResourcesDevDebug'.
Crashlytics Developer Tools error.

Any help would be appreciated.

Annice answered 12/10, 2015 at 17:13 Comment(3)
I also get this issue. I also tried adding the "apiKey" to the fabric.properties folder but that did NOT solve the issue either. It seems the plugin pulls the API key directly from the manifest, without following string references.Escort
This is still the case, shame Fabric haven't changed this as Android Studio has really useful build type switching.Jacal
I think Fabric needs to be notified of this. Just taking a string reference shouldn't be difficult. String references work fine with the meta-tag of Google Play Services!Anguilliform
P
0

Try refreshing kit-libs folder by right clicking on "kit-libs" and then selecting refresh kits.

Piacular answered 20/10, 2015 at 5:16 Comment(1)
Where is this folder?Escort
L
0

I just looked into this pretty closely. This doesn't work because the android:value attribute is taken literally. To use a resource id you'd have to use android:resource attribute instead but the Fabric gradle plugin does not make use of this android:resource attribute at all because it processes the manifest as an XML document rather than as an Android Manifest class.

After decompiling the Fabric source code and figuring out how the DefaultManifestData and StandardAndroidProject classes work, I confirmed the following:

The Easiest Way to Provide a Separate ApiKey for Debug Builds

Leverage manifest merging by creating app/src/debug/AndroidManifest.xml with the following contents (you must use the tools:replace attribute for this to work):

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <application>
        <!-- Meta-data -->
        <meta-data
            android:name="io.fabric.ApiKey"
            android:value="[yourDebugApiKey]"
            tools:replace="android:value"/>
    </application>

</manifest>

Your debug ApiKey is located in your project's Organization Settings page.

Lexicon answered 28/2, 2018 at 17:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.