lost baby
lost baby

Reputation: 3268

What is this Gradle build Error after installing Fabric Crashlytics in my android firebase app?

I tried to manually add Fabric Crashlytics and then tried to use the plugin but got the same error when I try to build:

Error:Execution failed for task ':app:processReleaseManifest'.
> Manifest merger failed : Attribute meta-data#io.fabric.ApiKey@value value=( my api key ) from AndroidManifest.xml:39:13-69
    is also present at [com.firebaseui:firebase-ui-auth:1.2.0] AndroidManifest.xml:20:13-60 value=(@string/twitter_consumer_secret).
    Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:37:9-39:72 to override.

I added the line suggested (even though I don't really understand it or know if it will cause a conflict of some sort with firebase-ui-auth )

tools:replace="android:value"

and now I can build and run the app but when I force a crash like so:

throw new RuntimeException("This is a crash");

I get crash reports though it took awhile for them to appear.

My gradle file looks like so:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}




// Create a variable called keystorePropertiesFile, and initialize it to your
// keystore.properties file, in the rootProject folder.
def keystorePropertiesFile = rootProject.file("keystore.properties")

// Initialize a new Properties() object called keystoreProperties.
def keystoreProperties = new Properties()

// Load your keystore.properties file into the keystoreProperties object.
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))





android {
    signingConfigs {
        config {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    compileSdkVersion 25
    buildToolsVersion '25.0.3'
    defaultConfig {
        applicationId "aaa.bbb.ccc"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        signingConfig signingConfigs.config

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
        debug {
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.1'
    compile 'com.android.support:design:25.1.1'
    compile 'com.android.support:support-v4:25.1.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:recyclerview-v7:25.1.1'
    compile 'com.google.android.gms:play-services-auth:10.2.4'
    compile 'com.firebaseui:firebase-ui:1.2.0'
    compile 'com.firebaseui:firebase-ui-auth:1.2.0'
    compile 'com.google.firebase:firebase-auth:10.2.4'
    compile 'com.google.firebase:firebase-core:10.2.4'
    compile 'com.google.firebase:firebase-database:10.2.4'
    compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    testCompile 'junit:junit:4.12'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true;
    }
}


apply plugin: 'com.google.gms.google-services'

and in my manifest I have the internet permission which was working already and now:

<meta-data
        tools:replace="android:value"
        android:name="io.fabric.ApiKey"
        android:value=" my key " />

My Android Studio is version 2.3.2 So, is the manifest fix going to cause a problem down the road - is the initial build error still an issue? Is there something I might be missing to avoid the initial build error? Thanks

PS the full manifest file is:

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

    <uses-sdk tools:overrideLibrary="com.firebase.ui, com.firebase.ui.auth"/>

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity
            android:name=".MainNavDrawerActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar"
            android:screenOrientation="portrait"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:windowSoftInputMode="stateHidden|adjustResize">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <meta-data
            tools:replace="android:value"
            android:name="io.fabric.ApiKey"
            android:value=" my key " />
    </application>

</manifest>

Upvotes: 2

Views: 1227

Answers (1)

Mohamed ALOUANE
Mohamed ALOUANE

Reputation: 5407

I had the same issue, Delete this from your manifest file:

tools:replace="android:value"

It's better to have the keys inside gradle like this :

manifestPlaceholders = [fabric_io_id: "key here "]

And add it to

       <meta-data
          android:name="io.fabric.ApiKey"
          android:value="${fabric_io_id}"
          tools:replace="android:value"/>

Upvotes: 7

Related Questions