14

I am trying to add Firebase crashlytics to our project but just can not get it to work.

I have followed the instructions adding the necessary lines to our gradle file but no success so far.

The main issue I get is this message: Crashlytics found an invalid API key: null

which seems weird since I thought an API key should not be needed for Firebase.

I use Android studio 3.0.1 with the latest gradle plugin. My project is Ionic based but I have tried to hand modify the gradle file as well with the same results.

user1816142
  • 1,199
  • 2
  • 9
  • 16
  • Mike from Firebase here. Currently Firebase Crashlytics does not support Ionic based apps. – Mike Bonnell Mar 02 '18 at 00:35
  • Thanks for the reply Mike, can you share some more details? I am not targeting the html part of the app but the Android part. We use several Firebsase components successfully in our Android app using the cordova-firebase plugin. There is also another repo called cordova-plugin-firebase-crashlytics and I am in contact with that guy on github and he says it works for him. – user1816142 Mar 02 '18 at 09:24
  • Sorry, I know very little about Cordova so I'm not sure how helpful I can be. If you're seeing that error message, then it means there is some reference to Fabric within the app, when if you're starting fresh with Firebase Crashlytics, you would need to follow the steps here: https://firebase.google.com/docs/crashlytics/get-started – Mike Bonnell Mar 02 '18 at 15:05
  • Having the exact same problem... very confusing, tried the plugin, got this error, followed firebase instructions and I'm back in the same place... bit of a weird one, no other hints of fabric in any other areas of the app – P110 Mar 08 '18 at 10:50
  • Seeing same issue with standard android app. – John O'Reilly Mar 10 '18 at 12:42
  • 1
    Ended up initializing manually (instead of using plugin) and it worked then (might also be related to fact that I'm also initialising Firebase manually). – John O'Reilly Mar 10 '18 at 13:54
  • same issue with multi module app. not sure where to apply the plugin. in base? or in installed? – Gillis Haasnoot Jul 03 '18 at 19:39

3 Answers3

25

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)

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

After that it is working

Rafols
  • 1,299
  • 14
  • 12
4

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

You can check with the Merged Manifest in Android Studio, to see if that is the case:enter image description here

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:

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

nicopico
  • 3,606
  • 1
  • 28
  • 30
0
    # Fabric properties file: app/fabric.properties    

apiSecret=x8x6x5x54x4xx8xxxx98 #your api hash

apiKey=xx389xxx8xx7x787x8x7x78x78x9x #api key

if you added api key in manifest remove it

Akshay
  • 318
  • 1
  • 15