用过firebase崩溃收集的应该都知道底层崩溃信息中如果没有通过符号表解析的话是很难确定崩溃位置的,那么firebase中该如何上传符号表呢?
一. Firebase 集成
1.前提条件:需要集成firebase Crashlytics ndk的库
dependencies {
......
implementation 'com.google.firebase:firebase-crashlytics-ndk'
}
2.集成流程
Firebase:https://firebase.google.com/docs/crashlytics/ndk-reports
build.gradle(app):
plugins {
id 'com.android.application'
// Make sure that you have the Google services Gradle plugin
id 'com.google.gms.google-services'
// Add the Crashlytics Gradle plugin
id 'com.google.firebase.crashlytics'
...
}
// ...
android {
// ...
buildTypes {
release {
// Add this extension
firebaseCrashlytics {
// Enable processing and uploading of native symbols to Firebase servers.
// By default, this is disabled to improve build speeds.
// This flag must be enabled to see properly-symbolicated native
// stack traces in the Crashlytics dashboard.
nativeSymbolUploadEnabled true
strippedNativeLibsDir 'build/intermediates/stripped_native_libs/debug/out/lib'
}
}
}
}
dependencies {
// Add the dependencies for the Crashlytics NDK and Analytics libraries
// When NOT using the BoM, you must specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-crashlytics-ndk:18.3.2'
implementation 'com.google.firebase:firebase-analytics:21.2.0'
}
build.gradle(project):
buildscript {
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
dependencies {
...
// Make sure that you have the Google services Gradle plugin dependency
classpath 'com.google.gms:google-services:4.3.14'
// Add the dependency for the Crashlytics Gradle plugin
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
}
}
二、自动上传符号表
在AS terminal中输入以下命令上传符号表,此方式依赖gradle
debug:./gradlew app:assembleDebug app:uploadCrashlyticsSymbolFileDebug -debug
release:./gradlew app:assembleRelease app:uploadCrashlyticsSymbolFileRelease
三、手动上传符号表
1.下载安装 Firebase CLI:https://firebase.google.com/docs/cli
2.运行CLI 并登录firebase账号,注:打开后如果没有登录过会自动打开浏览器让你登录账号
3.输入命令上传符号表
firebase crashlytics:symbols:upload --app=FIREBASE_APP_ID PATH/TO/SYMBOLS
FIREBASE_APP_ID :您的 Firebase Android 应用 ID(不是您的包名称)
示例 Firebase Android 应用程序 ID: 1:567383******:android:17104a2********
PATH/TO/SYMBOLS : CLI 生成的符号文件的路径
导出到 Android Studio 项目 — PATH/TO/SYMBOLS可以是任何目录。 Firebase CLI 将递归地在指定目录中搜索扩展名为.so的本机库。
直接从 Unity 中构建 APK — PATH/TO/SYMBOLS是构建完成后在项目根目录中生成的压缩符号文件的路径(例如: myproject/myapp-1.0-v100.symbols.zip )。
至此,firebase符号表上传就完成了,这样就可以在firebase中查看到底层的具体崩溃信息了~~