15

I followed all the steps on the docs to use Firebase Crash Reporting in my Android app (I use Android Studio and everything is up-to-date).

I used their own code to throw an exception to see if it works:

try {
    throw new NullPointerException();
} catch (NullPointerException ex) {
    FirebaseCrash.logcat(Log.ERROR, TAG, "NPE caught");
    FirebaseCrash.report(ex);
}

And the console gives me this log:

E/MainActivity: NPE caught

V/FirebaseCrash: Firebase Crash Reporting is disabled.

Here is one build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'

        // Firebase - Google Services 3.0.0
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Here is the other build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'android-N'
    buildToolsVersion '24.0.0-rc2'

    defaultConfig {
        applicationId "com.app.test"
        minSdkVersion 19
        targetSdkVersion 'N'
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            useProguard true
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:24.0.0-alpha1'
    compile 'com.android.support:appcompat-v7:24.0.0-alpha1'
    compile 'com.android.support:design:24.0.0-alpha1'
    compile 'com.google.firebase:firebase-core:9.0.0'
    compile 'com.google.firebase:firebase-analytics:9.0.0'
    compile 'com.google.firebase:firebase-crash:9.0.0'
    compile 'com.google.firebase:firebase-messaging:9.0.0'
    compile 'com.google.firebase:firebase-config:9.0.0'
    compile 'com.google.firebase:firebase-invites:9.0.0'
    compile 'com.google.android.gms:play-services-appindexing:9.0.0'
}

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

I also use:

mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
FirebaseMessaging.getInstance().subscribeToTopic("news");
Log.d(TAG, "Subscribed to news topic");

I added all dependencies that I'll need, but I'm adding one by one and testing one by one, and Notifications works, Analytics: no idea, it takes about 24 hours to update, so until it does, I don't know if is working...

So, the thing is how can I enable it?

NOTE: I have all of the dependencies added including the crash and core ones, also the plugin and the classpath

Thank you in advanced.

Community
  • 1
  • 1
Minion
  • 2,497
  • 4
  • 27
  • 29
  • Did you add also the google-services.json file? – Gabriele Mariotti May 23 '16 at 15:34
  • Yes, I followed all the steps on the docs and also on the console as I added the app – Minion May 23 '16 at 15:42
  • Can you please edit the question to include your gradle files, and any other places that you have called to Firebase methods? – WoogieNoogie May 23 '16 at 17:31
  • Did it, I also have a service for notifications and other Analytics, but as I said, it takes about 24 hours to update the console, so I don't know if that is working as Notifications or not as Crash Reporting... – Minion May 23 '16 at 17:54
  • Crashes are updated within 20 mins – Tim May 23 '16 at 17:58
  • Yes, but they are not sending, it says that Firebase Crash Reporting is disabled, what is updated every 24 hours is Firebase Analytics – Minion May 23 '16 at 18:01
  • Have you tried to enable the `Mobile Crash and Performance Reporting API`? See [this](https://console.developers.google.com/apis/api/mobilecrashreporting.googleapis.com/overview). –  May 24 '16 at 15:25
  • Hi, yes, I've been using that in other projects, but I decided to use Firebase in this one because it has no limits (at least while it still in Beta), besides, in this project I don't use any private servers, it's just the app and Google (Firebase) servers only, so I don't have any authentication or personal information. – Minion May 24 '16 at 16:39
  • Could you try using support design library 23, there is currently an issue when both firebase-:9.0.0 and support:design:24 are used together. – Arthur Thompson May 24 '16 at 20:22
  • It will make me change tons of lines of code, I'm using a lot of new APIs on Android N, I'm going to change all of it and when I'd do it and test it, I'll let you know, but I really hope Google pushes an update to fix the issues if that's what it's causing it, thanks. – Minion May 24 '16 at 20:45
  • Can you verify what version of Google Play Services is installed on your test device or emulator? Firebase requires Play Service 9.0 or later to work correctly. Crash Reporting will not init with earlier versions. – Doug Stevenson May 24 '16 at 23:36
  • Google Play services 8.9.25 (480-119544836), so it must be that, changing the complete code makes no difference, is there any way to update it on the emulator (Android N)? EDIT: Firebase Notification works perfect, even with the topics subscriptions, but Analytics and Crash Reporting do not work at all. – Minion May 25 '16 at 14:03
  • Try `compile 'com.google.android.gms:play-services:9.0.0'` instead `com.google.android.gms:play-services-appindexing:9.0.0`. It may helps you. – pRaNaY May 27 '16 at 03:41
  • I tried that and still not work... – Minion May 27 '16 at 13:22
  • 1
    The device or emulator must have Google Play services 9.0.x installed. If your device has Google Play services 8.9.25 then Firebase Crash Reporting and Firebase Analytics will not work. Once the device/emulator is updated to the latest version of Google Play services, it should work as expected. – Arthur Thompson May 27 '16 at 17:50
  • Hi @Arthur Thompson, any idea to update it on the emulator? – Minion May 27 '16 at 17:51
  • 1
    Please check [this video tutorial](https://www.youtube.com/watch?v=DOJ2BfZ5lak). It has full detailed explanation. – Chintan Rathod Oct 24 '16 at 13:47
  • @Minion , I am getting this error wile sending crash report, what should be wrong? E/FirebaseCrash: Error sending crash report: IOException while sending a crash report – Kostya M Jul 09 '18 at 11:44

6 Answers6

19

Please note the following:

  • After adding the SDK you can try using:

    FirebaseCrash.report(new Exception("My first Android non-fatal error"));

  • Errors take up to 20 minutes to show up in the Crash Reporting console. Check back to see your report there.

  • (It may seem obvious but) make sure you have:INTERNET and ACCESS_NETWORK_STATE permission.

yaircarreno
  • 4,002
  • 1
  • 34
  • 32
  • Hello, thanks, I know that, as people helped me in comments, this _malfunction_ it's caused by the Google Play Services that is outdated on the Android N emulator, I'm looking forward to update it, but seems to be impossible. – Minion May 29 '16 at 15:44
  • It can be even more than 20 minutes. I just received `V/FA-SVC: Upload scheduled in approximately ms: 1264312` which is approximately 21 minutes and I also saw 22 minutes in the logs as well. So just give it some time. ;) Unfortunately there doesn't seem to be a way to flush. – ubuntudroid Oct 30 '16 at 17:52
  • Although it seems that the reporting section is really broken - for me it just works veeery randomly. Approximately just 1 out of 20 refreshes. The majority of the tries it just says "We just caught an error! We're processing the error data and will show it to you shortly." – ubuntudroid Oct 30 '16 at 18:04
  • uh, and they say in docs `it takes 1-2 minutes for errors to show there`: https://firebase.google.com/docs/crash/android#create_your_first_error – marcinj Dec 10 '16 at 13:26
  • Hi @yaircarreno. Just wanted to verify if the `INTERNET` and `ACCESS_NETWORK_STATE` permissions are actually required? If so, do you have any reference? :) I was looking through the Quickstart for Crash Reporting, but there wasn't anything added in the [manifest](https://github.com/firebase/quickstart-android/blob/master/crash/app/src/main/AndroidManifest.xml) there. Or is it that documentations are lacking? Thanks! :) – AL. Mar 14 '17 at 06:23
4

Crash reporting was not working for me too after correctly setting it up in my App. To fix this I visited my developer console, API Manager, and enabled the "Mobile Crash and Performance Reporting API". To find out exactly where you need to do this follow the steps on this page.

If you follow the steps in the link above, the logcat that has the text "E/FirebaseCrashSenderServiceImpl: Error sending crash report" gives you a URL to where you must go in the console to enable crash reporting.

pbm
  • 5,081
  • 4
  • 18
  • 31
  • I could not find "Mobile Crash and Performance Reporting API" in any deveoper console. – sembozdemir Jun 15 '16 at 06:21
  • Did you follow the steps I suggested (in the link) to generate the crash that would give you the EXACT url you need to get to this screen? Click that and it will take you to the screen you cannot find. Don't blame me and vote me down if you cannot find this - I don't work for google so am not responsible! – pbm Jun 15 '16 at 07:58
  • 1
    This was also the issue with me, no idea why it's not documented at all in the Firebase Crash docs (perhaps because it's beta). The URL in the logs was: https://console.developers.google.com/apis/api/mobilecrashreporting.googleapis.com/overview?project= – MrBigglesworth Jul 21 '16 at 15:10
1

The FirebaseCrash is deprecated. The FirebaseCrashlytics.getInstance() should be used instead:

FirebaseCrashlytics.getInstance().log(message)
FirebaseCrashlytics.getInstance().recordException(throwable)

Source: https://firebase.google.com/docs/crashlytics/customize-crash-reports?platform=android#add-logs

siergiejjdw
  • 601
  • 5
  • 7
0

Add following code: In Project-level build.gradle (/build.gradle):

buildscript {
dependencies {

// Add this line
classpath 'com.google.gms:google-services:3.0.0'
}
}

In App-level build.gradle (//build.gradle):

// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'


//Add following in In App-level build.gradle
compile 'com.google.firebase:firebase-crash:9.0.0'

Now sync your project, Use following code in your activity to throw exception:

FirebaseCrash.report(new Exception("App Name : My first Android non-fatal error"));

check android crash reporting tutorial using firebase for complete guidance.

Umair Ahmed
  • 79
  • 2
  • 10
0

I had the same issue. Turns out I was missing dependency in my project gradle file. Try adding this. It should help.

buildscript {
      repositories {
        jcenter()
        // ...
      }

      dependencies {
        // ...
        classpath 'com.google.firebase:firebase-plugins:1.0.5'
      }
    }
Zhangali Bidaibekov
  • 591
  • 1
  • 7
  • 13
0

You should allow some time to show up. Even though the documentation says the errors will show up within 5 minutes, it can take up to 15-20 minutes. Also, you have to change your old modules to AndroidX by migrating it if you use native development. Finally, make sure that all the tools and plugins are added in the appropriate Gradle files.

Haileapp
  • 755
  • 7
  • 20