在我的android firebase应用程序中安装Fabric Crashlytics后,这个Gradle构建错误是什么?

时间:2017-05-21 10:07:34

标签: android firebase firebase-authentication crashlytics

我尝试手动添加Fabric Crashlytics,然后尝试使用该插件,但在尝试构建时遇到了同样的错误:

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.

我添加了建议的行(即使我不太了解它或知道它是否会导致与firebase-ui-auth的某种冲突)

tools:replace="android:value"

现在我可以构建并运行应用程序了,但是当我强制崩溃时:

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

我收到了崩溃报告,虽然他们需要一段时间才能出现。

我的gradle文件如下所示:

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'

在我的清单中,我已经获得了互联网许可,现在已经有效了:

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

我的Android Studio版本为2.3.2 那么,明显的修复是否会导致问题 - 最初的构建错误仍然是一个问题?是否有一些我可能会遗漏以避免初始构建错误? 感谢

PS完整清单文件是:

    <?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>

1 个答案:

答案 0 :(得分:7)

我有同样的问题, 从清单文件中删除它:

tools:replace="android:value"

将键放在gradle中会更好:

manifestPlaceholders = [fabric_io_id: "key here "]

并将其添加到

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