0

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.

DuhVir
  • 447
  • 1
  • 4
  • 15

1 Answers1

0

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

Mittal Varsani
  • 5,601
  • 2
  • 15
  • 27
  • Yes, that's good solution. I just forget to say, that I can't use google-play or services. It's a standalone device. – DuhVir Oct 11 '19 at 09:44