Crashlytics 已经为我的 Android 应用程序设置了一段时间,并且适用于普通的 Java/Kotlin 代码。我现在正在尝试让 Crashlytics 使用本指南记录 NDK 崩溃:https://firebase.google.com/docs/crashlytics/ndk-reports .
我使 C++ 崩溃,它确实出现在 Crashlytics 中,如下面的屏幕截图所示。但是堆栈跟踪缺少很多信息。
顶级 Gradle 文件
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.61'
ext.ktlint_version = '0.33.0'
ext.spotless_version = '3.25.0'
repositories {
mavenCentral()
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.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.31.2'
classpath "com.diffplug.spotless:spotless-plugin-gradle:$spotless_version"
}
}
apply plugin: "com.diffplug.gradle.spotless"
allprojects {
repositories {
mavenCentral()
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
spotless {
kotlin {
target "**/*.kt"
ktlint(ktlint_version)
}
}
其他 Gradle 文件。注释行是我尝试过的东西。
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
def superpowered_sdk_path = new File(projectDir, '../../Superpowered/Superpowered')
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.something.app"
minSdkVersion 21
targetSdkVersion 28
versionCode 51
versionName "51"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk { // these platforms cover 99% percent of all Android devices
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
}
externalNativeBuild {
cmake {
arguments '-DANDROID_PLATFORM=android-19', '-DANDROID_TOOLCHAIN=clang', '-DANDROID_ARM_NEON=TRUE', '-DANDROID_STL=c++_static', "-DPATH_TO_SUPERPOWERED:STRING=${superpowered_sdk_path}"
cFlags '-O3', '-fsigned-char' // full optimization, char data type is signed
cppFlags '-fsigned-char', "-I${superpowered_sdk_path}"
}
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path file('CMakeLists.txt')
}
}
afterEvaluate {
assembleDebug.finalizedBy(crashlyticsUploadSymbolsDebug)
assembleRelease.finalizedBy(crashlyticsUploadSymbolsRelease)
}
// android.applicationVariants.all { variant ->
// def variantName = variant.name.capitalize()
// if(variant.buildType.name=="release") {
// println('Calling crashlyticsUploadSymbolsRelease...')
// variant.assemble.finalizedBy(project.("crashlyticsUploadSymbols${variantName}"))
// }
// }
// tasks.whenTaskAdded { task ->
// if (task.name == "externalNativeBuildRelease") {
// println('Calling crashlyticsUploadSymbolsRelease...')
// task.finalizedBy "crashlyticsUploadSymbolsRelease"
//// crashlyticsUploadSymbolsRelease
// } else if (task.name == "externalNativeBuildDebug") {
// println('Calling crashlyticsUploadSymbolsDebug...')
// task.finalizedBy "crashlyticsUploadSymbolsDebug"
//// crashlyticsUploadSymbolsRelease
// }
// }
}
crashlytics {
enableNdk true
// androidNdkOut 'build/intermediates/cmake/debug/obj'
// androidNdkLibsOut 'build/intermediates/stripped_native_libs/debug/out/lib'
// androidNdkOut 'build/intermediates/cmake/release/obj'
// androidNdkLibsOut 'build/intermediates/merged_native_libs/debug/out/lib'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
testImplementation 'androidx.test:core:1.2.0'
testImplementation "io.mockk:mockk:1.9.3"
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.karumi:dexter:6.0.2'
implementation 'org.koin:koin-android:0.9.2'
implementation 'com.android.billingclient:billing:1.1'
implementation 'com.google.android.exoplayer:exoplayer:2.11.1'
implementation('com.github.bumptech.glide:glide:4.10.0') {
exclude group: "com.android.support"
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.google.firebase:firebase-ads:18.3.0'
implementation 'com.google.firebase:firebase-core:17.2.0' //17.2.1 Has a bug
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation('com.crashlytics.sdk.android:crashlytics-ndk:2.1.1')
implementation "android.arch.navigation:navigation-fragment-ktx:1.0.0"
implementation "android.arch.navigation:navigation-ui-ktx:1.0.0"
implementation 'com.beust:klaxon:5.0.1'
implementation 'com.h6ah4i.android.widget.verticalseekbar:verticalseekbar:1.0.0'
implementation 'us.belka:androidtoggleswitch:1.2.2'
implementation 'com.shawnlin:number-picker:2.4.8'
implementation 'com.github.Triggertrap:SeekArc:v1.1'
implementation 'com.sdsmdg.harjot:croller:1.0.7'
implementation 'com.jaredrummler:material-spinner:1.3.1'
implementation 'com.jakewharton.threetenabp:threetenabp:1.2.1'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-3'
}
我认为问题在于“上传 native 符号”步骤。我读过另一个 post运行后
./gradlew crashlyticsUploadSymbolsRelease
或 ./gradlew crashlyticsUploadSymbolsDebug
应该有一行“成功上传的符号”。运行任务后我没有看到这一行,也没有看到任何错误(我使用过 --info 和 --debug)。我已经四处寻找其他帖子上建议的不同类型的解决方案,但似乎没有任何效果。版本
在上传符号之前还有什么需要做的吗?有没有办法检查它们是否上传成功?
谢谢!
最佳答案
在联系 Crashlytics 帮助台时,我采取了一些步骤来为他们提供一些日志。在完成这些步骤时,一切正常,堆栈跟踪按预期显示在 Crashlytics 中。
以防有人遇到任何问题。检查 crashlytics 日志(感谢帮助台提供这些步骤!):
Linux/Windows:~/.crashlytics/com.crashlytics.tools/crashlytics.log
Mac:~/Library/Caches/com.crashlytics/com.crashlytics.tools/crashlytics.log
检查 crashlytics.log,它应该包含如下内容:
[DEBUG] (Execution worker for ':' Thread 6) com.crashlytics - Manifest and properties apiKey is empty. Looking for google_app_id
[DEBUG] (Execution worker for ':' Thread 6) com.crashlytics - Google-services res dir: /Users/xxx/AndroidStudioProjects/Looper/app/build/generated/res/google-services/release/values/values.xml
[DEBUG] (Execution worker for ':' Thread 6) com.crashlytics - Found google_app_id: 1:12341234123:android:34h43h2k423342kb
[DEBUG] (Execution worker for ':' Thread 6) com.crashlytics - apiKey is 123412341234fdsfds12312321321dsfsd
[DEBUG] (Execution worker for ':' Thread 6) com.crashlytics - Crashlytics attempting to upload cSYM files.
[DEBUG] (Execution worker for ':' Thread 6) com.crashlytics - POST file: /Users/xxx/Library/Caches/com.crashlytics/com.crashlytics.tools/app-afdsfdsfdsfds/release/csyms/superpowered-aarch64-b4jk32bkl2b5b4b543.cSYM.gz to URL: https://cm.crashlytics.com/api/v3/platforms/android/code_mappings
[DEBUG] (Execution worker for ':' Thread 6) com.crashlytics - POST response: [reqId= 123412341234fdsfds12312321321dsfsd] 202
[DEBUG] (Execution worker for ':' Thread 6) com.crashlytics - POST file: /Users/xxx/Library/Caches/com.crashlytics/com.crashlytics.tools/app-af3ed5c17e31fe86dd60a032b9674cb18b65334d/release/csyms/superpowered-x86_64-123412341234fdsfds12312321321dsfsd.cSYM.gz to URL: https://cm.crashlytics.com/api/v3/platforms/android/code_mappings
[DEBUG] (Execution worker for ':' Thread 6) com.crashlytics - POST response: [reqId=123412341234fdsfds12312321321dsfsd] 202
[DEBUG] (Execution worker for ':' Thread 6) com.crashlytics - POST file: /Users/xxx/Library/Caches/com.crashlytics/com.crashlytics.tools/app-af3ed5c17e31fe86dd60a032b9674cb18b65334d/release/csyms/superpowered-x86-123412341234fdsfds12312321321dsfsd.cSYM.gz to URL: https://cm.crashlytics.com/api/v3/platforms/android/code_mappings
[DEBUG] (Execution worker for ':' Thread 6) com.crashlytics - POST response: [reqId=123412341234fdsfds12312321321dsfsd] 202
[DEBUG] (Execution worker for ':' Thread 6) com.crashlytics - POST file: /Users/xxx/Library/Caches/com.crashlytics/com.crashlytics.tools/app-123412341234fdsfds12312321321dsfsd/release/csyms/superpowered-armv7-123412341234fdsfds12312321321dsfsd to URL: https://cm.crashlytics.com/api/v3/platforms/android/code_mappings
[DEBUG] (Execution worker for ':' Thread 6) com.crashlytics - POST response: [reqId=123412341234fdsfds12312321321dsfsd] 202
[DEBUG] (Execution worker for ':' Thread 6) com.crashlytics - cSYM file(s) uploaded.
编辑:
尝试上传发布符号时,我遇到了同样的问题。堆栈跟踪没有显示出来。在重建我的项目和另一个
./gradlew crashlyticsUploadSymbolsRelease
之后一切正常。编辑2:
确保在 gradle.properties 中将此值设置为 false
android.bundle.enableUncompressedNativeLibs=false
关于Android Crashlytics - 无法上传符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60142763/