简体   繁体   English

将Firebase Crashlytics添加到Android项目时出现问题 - Crashlytics发现无效的API密钥:null

[英]Problems adding Firebase Crashlytics to Android project - Crashlytics found an invalid API key: null

I am trying to add Firebase crashlytics to our project but just can not get it to work. 我正在尝试将Firebase crashlytics添加到我们的项目中,但却无法让它工作。

I have followed the instructions adding the necessary lines to our gradle file but no success so far. 我按照说明添加必要的行到gradle文件但到目前为止没有成功。

The main issue I get is this message: Crashlytics found an invalid API key: null 我得到的主要问题是这条消息:Crashlytics发现了一个无效的API密钥:null

which seems weird since I thought an API key should not be needed for Firebase. 这似乎很奇怪,因为我认为Firebase不需要API密钥。

I use Android studio 3.0.1 with the latest gradle plugin. 我使用Android studio 3.0.1和最新的gradle插件。 My project is Ionic based but I have tried to hand modify the gradle file as well with the same results. 我的项目是基于Ionic的,但我也试图手动修改gradle文件并获得相同的结果。

I had a similar problem and it turned out that I did not apply google-services plugin in the bottom of build.gradle (in app module) 我遇到了类似的问题,结果发现我没有在build.gradle的底部应用google-services插件(在app模块中)

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

After that it is working 之后它正在运作

There is an incompatibility with some other Firebase libraries that add the API key in the manifest for you, for example com.firebaseui:firebase-ui-auth:2.3.0 与其他一些Firebase库不兼容,可以在清单中为您添加API密钥,例如com.firebaseui:firebase-ui-auth:2.3.0

You can check with the Merged Manifest in Android Studio, to see if that is the case: 您可以使用Android Studio中的Merged Manifest查看是否是这种情况: 在此输入图像描述

The issue might be resolve by updating/removing the library if possible, otherwise you can remove the API key by adding a <meta-data> tag with a tools:node="remove" attribute, like this: 如果可能,可以通过更新/删除库来解决此问题,否则您可以通过添加带有tools:node="remove"属性的<meta-data>标记来删除API密钥,如下所示:

<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="your.package">

    <application
        ...>

        <meta-data
            android:name="io.fabric.ApiKey"
            tools:node="remove"/>

    </application>

</manifest>

This will tell the manifest merger that you don't want this specific meta-data. 这将告诉清单合并您不希望这个特定的元数据。

    # Fabric properties file: app/fabric.properties    

apiSecret=x8x6x5x54x4xx8xxxx98 #your api hash apiSecret = x8x6x5x54x4xx8xxxx98 #your api hash

apiKey=xx389xxx8xx7x787x8x7x78x78x9x #api key apiKey = xx389xxx8xx7x787x8x7x78x78x9x #api key

if you added api key in manifest remove it 如果你在清单中添加api密钥删除它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM