Hướng dẫn sử dụng Firebase Crash Reporting trong Android
Bài đăng này đã không được cập nhật trong 4 năm
Bước 1: Tạo project: Vào New -> Chọn New project.
Bước 2: Vào Firebase => Chọn Create New Project

Sau đó nhập tên project => Chọn Create project
Tiếp theo lựa chọn Android Platfom

Bước 3: Vào terminal và viết đoạn mã sau để lấy mã SHA-1
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
Bước 4: Nhập mã SHA-1, và nhập package name

Bước 5: Chọn Add App. Sau đó file google-services.json sẽ tự động được tải xuống, Copy file đó vào thư mục project

Bước 6: Copy đoạn mã Firebase SDK dependencies vào project Trong file build.gradle (Project)
buildscript {
dependencies {
// Add this line
classpath 'com.google.gms:google-services:3.0.0'
}
}
Trong file build.gradle (app)
apply plugin: 'com.android.application'
android {
....
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
...
//Add this
compile 'com.google.firebase:firebase-crash:9.4.0'
}
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
Sau đó chọn Sync now

Bước 7: Firebase Crash Reporting tự động báo lỗi nếu xảy ra crash app. Tuy nhiên, nếu bạn muốn gửi report với những trường hợp của bạn để debug app thì bạn có thể sử dụng câu lệnh:
Exception exception = new Exception("Oops! Firebase non-fatal error!");
FirebaseCrash.report(exception);
Một lựa chọn khác là bạn có thể gửi report bằng câu lệnh log()
FirebaseCrash.log("Button clicked!");
Kết quả

All rights reserved