11

In my application, I want to use firebase Crashlytics and for this, I added below codes into my application.
I added this codes step by step from google document!
I added below codes but when sync application show me an error and not sync project.

Build.gradle (project) :

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.1.0'
        classpath 'io.fabric.tools:gradle:1.26.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
        maven { url 'https://dl.bintray.com/tapsellorg/maven' }
        maven { url 'https://maven.google.com/' }
    }
}

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

Build.gradle (app) :

dependencies {
    implementation 'com.google.android.gms:play-services-base:16.0.1'
    implementation 'com.google.firebase:firebase-core:16.0.6'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.7'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'

but when added this line apply plugin: 'com.google.gms.google-services' , when click on sync show me below error :

The library com.google.android.gms:play-services-base is being requested by various other libraries at [[11.0.2,11.0.2]], but resolves to 16.0.1. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

How can I fix it?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Dr. Jake
  • 249
  • 2
  • 3
  • 9

7 Answers7

11

build.gradle Module

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


// add the Firebase SDK for Google Analytics
// The app need this to init in Firebase console
implementation 'com.google.firebase:firebase-analytics:17.2.1'

 // Add the Firebase SDK for Crashlytics.
implementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta01'

build.gradle Project

classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta01'

You do not need fabric.io anymore, it is deprecated and will be available until March 31, 2020. Take a look at this Project and Video

if after all Firebase doesn't recognize the app, record an exception using this recordException

AllanRibas
  • 678
  • 5
  • 14
7

in android studio 4.0 and above project level gradle

plugins {
    id 'com.android.application' version '7.1.0' apply false
    id 'com.android.library' version '7.1.0' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false

    
    id 'com.google.gms.google-services' version '4.3.10' apply false  // Google Services plugin
    // Crashlytics Gradle plugin
    id 'com.google.firebase.crashlytics' version '2.8.1' apply false
}

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

App level gradle

plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
}



dependencies {

implementation platform('com.google.firebase:firebase-bom:30.3.2')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-crashlytics'
}
Jayesh Dankhara
  • 525
  • 7
  • 8
1

I have followed the below steps to achieve adding the Firebase Crashlytics to the project,

1.Get the google-service json file and complete adding project to the firebase follow this link Firebase Console.

2.In project build.gradle file add the below code,

buildscript {
repositories {
    maven {
        url 'https://maven.fabric.io/public'
    }
    maven {
        url 'https://maven.google.com'
    }
}
 dependencies {
     // Check for v3.1.2 or higher
     classpath 'com.google.gms:google-services:4.3.2'
     // Add dependency
     classpath 'io.fabric.tools:gradle:1.31.2'
  }
}

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

3.Inside the app build.gradle file, add the below code,

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

and in dependencies add,

implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'

4.Induce the crash to check whether it gets reflected in the console in section crashlytics,

Crashlytics.getInstance().crash();

Hope it helps :)

Kavya Shravan
  • 333
  • 3
  • 6
  • The Fabric SDK is no longer supported as of November 15, 2020. To continue getting crash reports in the Firebase console, make sure you upgrade to the Firebase Crashlytics SDK . https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android – san88 Jun 23 '21 at 09:53
0

To enter Firebase Crashlytics the first thing you need to do is follow these simple steps:

In app-> build.gradle:

apply plugin: 'io.fabric'
dependencies {
 implementation "com.google.firebase:firebase-core:17.2.0"
// Add dependency
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
}

In general build.gradle:

buildscript {

repositories {

    maven {
        url 'https://maven.fabric.io/public'
    }
}
dependencies {
    classpath 'io.fabric.tools:gradle:1.31.2'  // Crashlytics plugin
}

Obviously after that, insert the json file in your project folder to connect your app to Firebase enter image description here

To do the first test and evaluate if everything is working properly, you don't need to initialize anything, because Crashlytics has the singleton. So go to the main screen of your app and not to Application (otherwise it won't work), and try this:

Crashlytics.getInstance().crash();

After doing the test, go to your app's Firebase panel and click on the Crashlytics button

AlexPad
  • 10,364
  • 3
  • 38
  • 48
0

Register your android app in firebase console and download google-play-services.json and paste under app in project directory.

Please follow below steps:

In project level build.gradle,add below dependency:

classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.1'

In app level build.gradle,add below plugin:

apply plugin: 'com.google.firebase.crashlytics'

In project level build.gradle,add below dependency:

implementation 'com.google.firebase:firebase-analytics:17.5.0' implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'

For checking,add below code to crash

Crashlytics.getInstance().crash();

Tarun Anchala
  • 2,232
  • 16
  • 15
-1

You don't need any dependency or.jar file to add crashlytics in your app just follow below steps and let me know if you face any error. Add the dependency on Google Analytics for Firebase to your app-level build.gradle file:

implementation 'com.google.firebase:firebase-core:16.0.6'

After this, Declare the com.google.firebase.analytics.FirebaseAnalytics object at the top of your activity:

private FirebaseAnalytics mFirebaseAnalytics;

Then initialize it in the onCreate() method:

// Obtain the FirebaseAnalytics instance.
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

That's it for more info refer to official docs of Firebase on How to integrate crashlytics (https://firebase.google.com/docs/analytics/android/start)

Note : mismatching of firebase libraries can give you gradle compilation errors

rajat singh
  • 165
  • 1
  • 11
  • so where can i get to monitor all the crashes ? – Shahjad Ans Sunny Sep 26 '19 at 11:19
  • All you crashes will be visible on firebase console, you can access them from left hand side menu under crashlytics section – rajat singh Sep 27 '19 at 12:50
  • According to the roadmap, the new Firebase SDK is not ready yet, they say keep using the crashlytics/fabric.io variant. See roadmap: https://get.fabric.io/roadmap#the-roadmap – arberg Dec 01 '19 at 19:40
-2
  1. in your build.gradle add:

    buildscript {
    repositories {
    
    // Add Google's Maven repository.
    google()
    
    maven {
       url 'https://maven.fabric.io/public'
    }
    }
    
    dependencies {
    // ...
    
    // Add the Google Services plugin (check for v3.1.2 or higher).
    classpath 'com.google.gms:google-services:4.3.3'
    
    // Add the Fabric Crashlytics plugin.
    classpath 'io.fabric.tools:gradle:1.31.2'
    
    }
    }
    
  2. Add your app level build.gradle

    apply plugin: 'com.android.application'
    apply plugin: 'com.google.gms.google-services'
    // Add the Fabric plugin.
    apply plugin: 'io.fabric'
    
    dependencies {
    // ...
    
    // (Recommended) Add the Google Analytics dependency.
    implementation 'com.google.firebase:firebase-analytics:17.2.3'
    
    // Add the Firebase Crashlytics dependency.
    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
    }
    
  3. Change min Sdk version to 16 in app level build.gradle.

You can go through this link for detailed description of how to connect to crashlytics http://blogssolutions.co.in/android-app-add-firebase-crashlytics/