Firebase Crashlytics Android NDK:崩溃报告上的空符号

问题描述 投票:3回答:1

我在Android Studio中有一个包含Android Java服务的项目,该项目通过JNI调用使用某些本机库。

[基本上,我有2个库可以编译,而另一个库是预编译的,因此我无权访问源代码。由于预编译的库仅针对armeabi-v7a构建,因此我有一个abiFilter。

这里,我的/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.2'
        classpath 'io.fabric.tools:gradle:1.31.2'
        classpath 'com.google.gms:google-services:4.3.3'  // Google Services plugin

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

和我的/app/build.gradle(省略了明智的代码)

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

def enableCrashlyticsNdk = true

repositories {
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
}

android {
    signingConfigs {
        platformSignature {
            keyAlias "${platform_keystore_alias}"
            keyPassword "${platform_keystore_password}"
            storeFile file("${platform_keystore_path}")
            storePassword "${platform_keystore_password}"
        }
    }

    compileSdkVersion 29
    buildToolsVersion "29.0.2"

    lintOptions {
        abortOnError false
    }

    defaultConfig {
        applicationId com.example.stackoverflowapp
        minSdkVersion 26
        targetSdkVersion 28
        versionCode 1
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags "-std=c++11 -Werror"
            }
        }
        ndk {
            // Specifies the ABI configurations of your native
            // libraries Gradle should build and package with your APK.
            abiFilters 'armeabi-v7a'
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            jniDebuggable false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.platformSignature
        }
        debug {
            debuggable true
            jniDebuggable true
            versionNameSuffix = " (debug)"
            signingConfig signingConfigs.platformSignature
        }
    }

    android.applicationVariants.all { variant ->
        variant.outputs.all {
            outputFileName = buildOutputName(variant)
        }
    }

    packagingOptions {
        exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
        exclude 'error_prone/Annotations.gwt.xml'
        exclude 'third_party/java_src/error_prone/project/annotations/Annotations.gwt.xml'
        exclude 'third_party/java_src/error_prone/project/annotations/Google_internal.gwt.xml'
    }

    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
            version "3.10.2"
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

ext {
    appCompatVersion = '28.0.0'
}

crashlytics {
    enableNdk enableCrashlyticsNdk
}

tasks.whenTaskAdded { task ->
    if (enableCrashlyticsNdk && task.name.startsWith('assemble')) {
        task.finalizedBy "crashlyticsUploadSymbols" + task.name.substring('assemble'.length())
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.leanback:leanback:1.0.0'
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'com.google.android.exoplayer:exoplayer:r1.5.14'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    implementation 'com.google.code.gson:gson:2.8.5'

    implementation 'com.google.firebase:firebase-analytics:17.2.1'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
    implementation 'com.crashlytics.sdk.android:crashlytics-ndk:2.1.1'
}

apply plugin: 'com.google.gms.google-services'  // Google Play services Gradle plugin

由于我的应用程序是Android系统的一部分,因此已使用平台签名进行了签名。

我用CMake编译我的2个库。

我已经按照Firebase网站上的所有步骤进行了操作:

  1. https://firebase.google.com/docs/android/setup
  2. https://firebase.google.com/docs/crashlytics/get-started?platform=android
  3. https://firebase.google.com/docs/crashlytics/ndk-reports

我有意在一个库中添加了崩溃,当应用崩溃时,Crashlytics收集了崩溃并成功上传了崩溃报告。

CrashlyticsCore: Crashlytics report upload complete: 5DE66A450116-0001-1A8B-A3EE77BA9366

然后,当我进入firebase控制台时,我看到所有堆栈帧都(丢失)

Crashed: Thread #1
SIGSEGV 0x0000000000000028
-------------------------------------------
0 MyApp.apk (Missing)
1 libart.so (Missing)
2 (Missing)
3 (Missing)
4 (Missing)
5 (Missing)
6 (Missing)
7 libart.so (Missing)
8 libart.so (Missing)
9 libart.so (Missing)
10 (Missing)
11 libart.so (Missing)
12 (Missing)

查看Crashlytics构建日志,似乎cSym文件已正确上传。

[DEBUG] (Execution worker for ':' Thread 6) com.crashlytics  - cSYM file(s) uploaded.

我不太确定这些符号是否正确创建和上载,或者设备创建的崩溃报告是否存在问题。我担心这个问题与Android权限有关,因为我的应用程序是系统应用程序。

我想我已经阅读了所有与Crashlytics和NDK相关的stackoverflow帖子。另外,我还用Google搜索了与“ crashlytics,ndk和符号”有关的任何组合。

最后,我正在使用的工具版本:

  • Android Studio:3.5.1
  • 等级:5.4.1
  • Gradle插件:3.5.2
  • Fabric gradle插件:1.31.2

非常感谢。

android firebase android-ndk crashlytics crashlytics-android
1个回答
2
投票

[您可能要考虑升级到新的(非结构)Crashlytics SDK。据推测,它是架构的替代路线。

https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android

https://firebase.google.com/docs/crashlytics/ndk-reports-new-sdk

虽然在撰写本文时它处于Beta版,但我最近很容易将其转换为它。在此过程中,我还可以停止在本机代码中使用结构本机库(libCrashlytics)及其标头。

此外,请确保在构建过程中将符号正确上传到Firebase / Fabric。您可能需要在afterEvaluate块中明确地执行此操作,如下所示:

afterEvaluate {
    if (gradle.startParameter.taskNames.contains(":app:assemble<Flavor><BuildType>")) {
        assemble<Flavor><BuildType>.finalizedBy(uploadCrashlyticsSymbolFile<Flavor><BuildType>)
    }
}

请确保将<Flavor><BuildType>替换为您在productFlavorsbuildTypes块中定义的风味和构建类型。

例如,以下风味/构建类型:

buildTypes {
    release {
        signingConfig signingConfigs.release
        buildConfigField "boolean", "RELEASE", "true"
        shrinkResources true
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
    debug {
        buildConfigField "boolean", "RELEASE", "false"
        applicationIdSuffix '.debug'
        versionNameSuffix '-DEBUG'
        ext.alwaysUpdateBuildId = false
        crunchPngs false
    }
}

flavorDimensions "all"

productFlavors {
    fat {
        ndk {
            abiFilters "x86_64", "x86", "arm64-v8a", "armeabi-v7a"
        }
        dimension "all"
    }
}

将导致您需要通过uploadCrashlyticsSymbolFileFatDebug和uploadCrashlyticsSymbolFileFatRelease任务最终完成的assembleFatDebug和assembleFatRelease任务。

注意:如果您仍在使用Fabric,则要用来完成assemble*任务的任务是crashlyticsUploadSymbols<Flavor><BuildType>

© www.soinside.com 2019 - 2024. All rights reserved.