How to add firebase crashlytics into android projects - java

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?

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

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'
}

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 :)

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

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();

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

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'
}
}
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'
}
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/

Related

External gradle plugin 'com.bmuschko.tomcat' not found

I want to add the tomcat plugin to my gradle build, but the plugin cannot be found , gradle shows the error
Plugin with id 'com.bmuschko.tomcat' not found.
I followed the steps on the github page of this plugin, but it does not work.
In my project I have general build.gradle in this I am loading my project.gradle in this I defined the tomcat-plugin configuration.
build.gradle
apply plugin: 'java'
apply plugin: 'maven'
sourceCompatibility = 1.8
ext {
debug = false
}
apply from: 'project.gradle'
group = myGroup
version = myVersion + '-SNAPSHOT'
project.gradle
//https://github.com/bmuschko/gradle-tomcat-plugin
buildscript {
repositories {
jcenter();
}
dependencies {
classpath 'com.bmuschko:gradle-tomcat-plugin:2.4.2'
}
}
apply plugin: "com.bmuschko.tomcat"
apply plugin: "idea"
apply plugin: "project-report"
apply plugin: "war"
I can ensure that dependencies can be resolved from my machine, because other gradle projects work, so that it should not be a network issue, there is no proxy configuration etc.
You have to put buildscript{} into your main build.gradle. The buildscript process is outside the regular Gradle build. Same applies to plugins{} as well (since they are equivalent.)
So if you put
buildscript {
repositories {
jcenter();
}
dependencies {
classpath 'com.bmuschko:gradle-tomcat-plugin:2.4.2'
}
}
into your build.gradle, it would work.
[Update]
I have created a sample gradle project with the fix in it.
And the TravisCI build is here.
Or you may try using the plugin type:
apply plugin: com.bmuschko.gradle.tomcat.TomcatPlugin
instead of
apply plugin: "com.bmuschko.tomcat"
in your project.gradle file.

use of libraries in android studio

com.google.firebase:firebase-core:11.2.2
com.google.firebase:firebase-database:11.2.2
com.google.firebase:firebase-storage:11.2.2
these libraries cannot seem to work,and i can't use providers such as google,Facebook,twitter to login in my android project. I've tried to updated the android studio and now i'm using android studio 2.3.3 and i'm using:
app:
compileSdkVersion 26
buildToolsVersion "26.0.1"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
project:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
As per the official Firebase Documentation you need to add Google's Maven repository to your project-level build.gradle:
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.1.0' // google-services plugin
}
}
allprojects {
// ...
repositories {
jcenter()
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
Then, in your module Gradle file (usually the app/build.gradle), add the apply plugin line at the bottom of the file to enable the Gradle plugin:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:11.2.2'
compile 'com.google.firebase:firebase-messaging:11.2.2'
// Getting a "Could not find" error? Make sure you have
// the latest Google Repository in the Android SDK manager
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

Android Studio 3.0 Canary 2: Failed to apply plugin, when using gradle 3.0.0-alpha2

I just updated to using Android Studio 3.0 Canary 2. Upon opening my project Android Studio suggested I update the gradle version to 3.0.0-alpha2. My goal is to use the "Enable advanced profiling" Run Configuration so I can run a realtime memory-analysis. However the instant my gradle version was updated, my project fails to build. I followed the update instructions here.
The only changes made were to my top-level build.gradle file and the gradle-wrapper.properties file.
My top-level build.gradle:
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha2'
classpath 'com.github.Archinamon:GradleAspectJ-Android:2.3.0'
classpath 'me.tatarka:gradle-retrolambda:3.5.0'
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url 'https://repo.adobe.com/nexus/content/repositories/releases/' }
maven { url 'http://maven.localytics.com/public' }
}
}
And I updated the gradle-wrapper.properties distributionURL to:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-1-all.zip
The error I get is:
Failed to apply plugin [id'com.archinamon.aspectJ']
And here is the offending part of my app-level build.gradle file:
import java.text.SimpleDateFormat
apply plugin: 'com.android.application'
apply plugin: 'com.archinamon.aspectj'
aspectj {
includeAspectsFromJar 'Android_MTAgent'
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
....
}
So the problem seems to be with the aspectJ plugin. If I remove the plugin for aspectJ and the related aspectJ block (both shown above) then it compiles (I get a dimen error then though, but I already saw that mentioned elsewhere, so I guess that can be solved.)
I'd appreciate any pointers/ideas in regard to the above issue.
Change your project build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha2'
}
to
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
}
and update your Archinamon classpath reference in the same build.gradle file to:
classpath 'com.github.Archinamon:GradleAspectJ-Android:3.0.2'

Android studio error:Error:(23, 0) Could not find method android() for arguments on root project

I reinstalled android studio, I am using the same project with android studio in another PC so the code is probably fine!
It is the full error:
Error:(23, 0) Could not find method android() for arguments [build_1z9k6ruj47plglocgqknjnoag$_run_closure3#133cf914] on root project 'allthingsvegan-android-9d296805dc64' of type org.gradle.api.Project.
Open File
The solutions I've found on the internet was including changing the code.. So they are not relevant to me
Thanks!!
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.2.0-beta1'
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
}
android {
buildToolsVersion '24.0.1'
}
It is the top-level build.gradle file.
In this file you can't use this block:
android {
buildToolsVersion '24.0.1'
}
Remove this block.
you need to apply the android plugin:
apply plugin: 'com.android.application'
this needs to be done after buildscript like this:
// 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.2.0-beta1'
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
}
apply plugin: 'com.android.application'
android {
buildToolsVersion '24.0.1'
}
uncomment android tag present in build.gradle(Project:android-start)
rebuild the gradle it asks to update .
Update the gradle then sync it works

occurred evaluating root project > plugin with com.android.application not found

Downloaded an android project having a problem I have this in a gradle file...
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.21.5'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
But I am getting the error..
Plugin with id 'com.android.application' not found
Any ideas what the problem is?
try in root gradle:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// 2.1.2 is newest plugin but required studio >= 2.1
classpath 'com.android.tools.build:gradle:1.5.0'
// The Fabric Gradle plugin uses an open ended version to react
// quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
in app or lib gradle:
apply plugin: 'com.android.application'
//Put Fabric plugin after Android plugin
apply plugin: 'io.fabric'
for fabric version plugin see:
https://s3.amazonaws.com/fabric-artifacts/repo/io/fabric/tools/gradle/maven-metadata.xml
<latest>1.21.5</latest>
<release>1.21.6</release>
btw don't use plus sign in libs/classes it's slows down the build process: instead classpath 'io.fabric.tools:gradle:1.+' use -> classpath 'io.fabric.tools:gradle:1.21.6'

Categories

Resources