Firebase Crashlytics
Firebase Crashlytics
Firebase Crashlytics
Firebase 集成
Firebase 集成步骤
- 注册 Firebase 账号
- 添加 Android 项目
- 添加包名,获取证书签名 SHA-1
keytool -list -v -alias hacket.alias -keystore hacket.keystore
- 下载
google-services.json
放到 app/根目录 - 添加 Firebase SDK
root build.gradle <project>/build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
buildscript {
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
dependencies {
// Add the dependency for the Google services Gradle plugin
classpath 'com.google.gms:google-services:4.3.15'
}
}
allprojects {
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
}
app build.gradle <project>/<app-module>/build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
plugins {
id 'com.android.application'
// Add the Google services Gradle plugin
id 'com.google.gms.google-services'
}
dependencies {
// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:31.2.3')
// TODO: Add the dependencies for Firebase products you want to use
// When using the BoM, don't specify versions in Firebase dependencies
implementation 'com.google.firebase:firebase-analytics-ktx'
// Add the dependencies for any other desired Firebase products
// https://firebase.google.com/docs/android/setup#available-libraries
}
- 集成其他 Firebase 服务
Firebase Crashlytics
Firebase Performance Monitoring
https://firebase.google.com/docs/perf-mon?authuser=0&hl=zh
遇到的问题
The Crashlytics build ID is missing
Caused by: java.lang.IllegalStateException: The Crashlytics build ID is missing. This occurs when Crashlytics tooling is absent from your app’s build configuration. Please review Crashlytics onboarding instructions and ensure you have a valid Crashlytics account.
检查一下 google-service.json
是否生成对了,是否用对了签名文件生成的
Caused by: javax.net.ssl.SSLProtocolException: Connection reset by peer: socket write error
网络问题
1
2
3
4
5
6
7
8
9
10
11
12
':Google:uploadCrashlyticsMappingFileRelease'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:187)
at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:268)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:185)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:173)
//...
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: org.gradle.api.UncheckedIOException: javax.net.ssl.SSLProtocolException: Connection reset
找不到符号
由于是 debug 包添加 bugly,release 包添加 Firebase
原因:debug 包的 getInstance() 没有添加 @JvmStatic
注解导致
1
2
3
4
5
E:\Workspace\allo-android\allo_client\src\main\java\com\live\allo\XChatApplication.java:486: 错误: 找不到符号
CrashPlatform.getInstance().init(this);
^
符号: 方法 getInstance()
位置: 类 CrashPlatform
解决:debug 和 release 包的代码包名都必须一致。
本文由作者按照 CC BY 4.0 进行授权