I have device with very poor debug capabilities, and it's inside car, can't connect it to PC. My program works on 3 different emulators and on my personal phone. but in car it sometimes crashes(like exception). I have no idea in which place of program it happens, so I can't just do try...catch and save printStackError. But I want save exception which leads to program termination to txt file.
All founded answers going to try...catch which not an option.
Does Android have something like onCrash or similar.
Update 1:
I can't use Google play or google-services, because it's standalone application without Google play on device.
You can use Firebase Crashlytics in your project. It will send the crash logs to the Crashlytics page in your firebase project window
Step 1
In your project-level build.gradle, update your google-services to
version 3.1.2 or later, then add the Crashlytics repositories and
dependency:
buildscript {
repositories {
// Add the following repositories:
google() // Google's Maven repository
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
// ...
// Check for v3.1.2 or higher
classpath 'com.google.gms:google-services:4.3.2' // Google Services plugin
// Add dependency
classpath 'io.fabric.tools:gradle:1.31.1' // Crashlytics plugin
}
}
allprojects {
// ...
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
// ...
}
}
Step 2
In your app-level build.gradle, add the Crashlytics
dependencies:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
dependencies {
// ...
// (Recommended) Add Analytics
implementation 'com.google.firebase:firebase-analytics:17.2.0'
// Add dependency
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
}
Here's the full document for Firebase Crashlytics
Related
I am new to flutter and firebase. I am trying develop an app with firebase as back end. To track the issues I thought of enabling the Crashlytics. I have enabled the crashlytics in the firebase console. i am getting the following message as Add SDK to your application
Added firebase_crashlytics to my application
Followed the instructions provided in the firebase_crashlytics
Android/build.gradle
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
classpath 'io.fabric.tools:gradle:1.28.0'
}
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
}
Andriod/App/build.gradle
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics:17.2.2'
}
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'
And updated my main file to initialize the firebase_crashlytics
I have manually thrown a null exception in the application. Which should be captured and shown on the crashlytic dashboard. Bit i am still getting add sdk loading icon in crashlytic dashboard. Please let me know what the issue. i have been working on this for past week.
I am able to save and read data with out any issue. I am working on my android app
Attached flutter doctor output
I added firebase crashlytics to my android app about a day ago. But I still see following getting started guide on the crashlytics page of the firebase console.
Following is my git diff for adding crashlytics.
project level gradle file:
## -5,10 +5,12 ## buildscript {
repositories {
jcenter()
google()
+ maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
- classpath 'com.google.gms:google-services:4.3.0'
+ classpath 'com.google.gms:google-services:4.3.2'
+ classpath 'io.fabric.tools:gradle:1.31.2' // Crashlytics plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
## -18,6 +20,7 ## allprojects {
repositories {
jcenter()
google()
+ maven { url 'https://maven.fabric.io/public' }
}
}
app level gradle file:
## -1,4 +1,5 ##
apply plugin: 'com.android.application'
+apply plugin: 'io.fabric'
android {
compileSdkVersion 29
## -93,6 +94,8 ## dependencies {
implementation 'com.google.firebase:firebase-firestore:21.2.0'
implementation 'com.google.firebase:firebase-auth:19.1.0'
implementation 'com.google.firebase:firebase-storage:19.1.0'
+ implementation 'com.google.firebase:firebase-analytics:17.2.0'
+ implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'net.cachapa.expandablelayout:expandablelayout:2.9.2'
implementation 'org.dizitart:nitrite:3.2.0'
implementation 'com.github.bumptech.glide:glide:4.9.0'
I crashed my app several times using following method.
Crashlytics.getInstance().crash();
My device has an internet connection.
I tested using both a debug build and a release build (signed apk).
What could be the reason the dashboard not showing up any crash statistics yet, even after a day of crashlytis setup in the app?
Add this at the bottom of the app level build gradle
apply plugin: 'com.google.gms.google-services' and add google json to your app folder
Remove the line "Crashlytics.getInstance().crash()",
Run your app on a Real Device,
Unplug device,
Close the app,
Open the app on your device as it's unplugged.
Now Check the FireBase again. You should see some charts in Crashlytics Tab.
For testing crashes you can do the above process, but this time with code "Crashlytics.getInstance().crash()".
Note: Be sure to place this line outside your App Delegate’s "didFinishLaunching" method
I followed the tutorial exactly (https://firebase.google.com/docs/crashlytics/get-started?authuser=1&platform=android#android) and still can't see my app on firebase Crashlytics. here's my configuration:
in root build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
classpath 'io.fabric.tools:gradle:1.31.0'
}
in app build.gradle
...
apply plugin: "io.fabric"
...
//Firebase
implementation 'com.google.firebase:firebase-core:17.0.1'
implementation 'com.google.firebase:firebase-config:18.0.0'
implementation 'com.google.firebase:firebase-analytics:17.0.1'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
in Application
Fabric.with(this, Crashlytics());
I'm building and running the app on debug but nothing is happening, in the logs I see
I/CrashlyticsInitProvider: CrashlyticsInitProvider skipping initialization
I/CrashlyticsCore: Initializing Crashlytics Core 2.7.0.33
what could I be missing?
For anyone who is facing a similar issue, I have looked for many hours and eventually checked the merged manifest and figured there is a 3rd party library that was actually setting up their own Crashlytics config which overrides mine. So maybe look into that.
I eventually added this to my manifest:
<meta-data
tools:node="remove"
android:name="io.fabric.ApiKey"/>
Refer to the Firebase Crashlytics Docs.
Step 1: Add this code in your project level build.gradle file
buildscript {
repositories {
// Add the following repositories:
google() // Google's Maven repository
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
// ...
// Check for v3.1.2 or higher
classpath 'com.google.gms:google-services:4.3.0' // Google Services plugin
// Add dependency
classpath 'io.fabric.tools:gradle:1.31.0' // Crashlytics plugin
}
}
allprojects {
// ...
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
// ...
}
}
Step 2 : Add this code in your app-level build.gradle file
apply plugin: 'io.fabric'
dependencies {
// ...
// Check for v11.4.2 or higher
implementation 'com.google.firebase:firebase-core:17.0.1'
// (Recommended) Add Analytics
implementation 'com.google.firebase:firebase-analytics:17.0.1'
// Add dependency
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
}
Make sure you have added google-services.json and running your app in physical device or emulator having google play services.
credit goes to firebase for creating such a helpful docs.
This is Zubair from Fabric/Firebase. Could you try to make individual build and run event on a brand new simulator (where they've not installed/ran this app before). If issue persist, reach out to us AT "support#fabric.io" and include app name/bundle id and firebase project id in the email.
i've been working with firebase to access an activity on my project. Everything works fine, no compilation errors. However after i go to tools > firebase i can connect to my app easily, however when i try to click Add Real time database it shows me this:
build.gradle will include these new dependencies:
compile 'com.google.firebase:firebase-database:16.0.1:15.0.0'
Since compile is deprecated i use implementation, and when i do
Implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'
i get the following error Failed to resolve: firebase-database-15.0.0
and my sync fails.
Change Root Gradle to
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
}
}
allprojects {
// ...
repositories {
// ...
google() // Google's Maven repository
}
}
And App Gradle To
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
// Getting a "Could not find" error? Make sure you have
// added the Google maven respository to your root build.gradle
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Hope This May Help You
add jcenter() in your project-level gradle.
allprojects {
repositories {
google()
jcenter()
}
}
and keep remaining as #Tomin B said.
How to this i am new on Android Studio.
The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.0,15.0.0], [15.0.2,15.0.2]], but resolves to 15.0.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
As reported here:
You will need to update the version of the latter dependency to 15.0.2. This addresses the issue where version 3.3.0 of the Google Services Gradle plugin reports: The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.0,15.0.0], [15.0.2,15.0.2]], but resolves to 15.0.2...
Then update your google play services plugin to 3.3.0
classpath 'com.google.gms:google-services:3.3.0'
and update the dependencies to 15.0.2.
Resolve this issue with me - If You are choosing Firestore Database then do this:
first We will add updated these things in Gradle :
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
}
}
allprojects {
// ...
repositories {
// ...
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
after this update :
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
implementation 'com.google.firebase:firebase-core:16.0.0'
// Getting a "Could not find" error? Make sure you have
// added the Google maven respository to your root build.gradle
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Then Rebuild or Sunc Now , issue will be resolve.
if You are working on RealTime Database then do this thing :-
Set Dependency :
implementation 'com.google.firebase:firebase-database:15.0.0'
and remove above FireStore Dependency.
This will sure resolve your issue ... If you like then vote for me
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
}
}
This works for me. By adding the latest version, i.e 4.0.1