Rene
Rene

Reputation: 127

Android Crashlytics - Unable to upload symbols

Crashlytics has been set up for my Android app for a while and working fine for normal Java/Kotlin code. I'm now trying to get Crashlytics to log NDK crashes using this guide: https://firebase.google.com/docs/crashlytics/ndk-reports.

I made the C++ crash and it does show up in Crashlytics as you can see in the screenshot below. But the stacktrace is missing a lot of info.

enter image description here

Top level Gradle file

// 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)
    }
}

Other Gradle file. The commented lines are things I tried.

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'
}

I think the problem is with the 'Upload native symbols' step. I've read on another post that after running ./gradlew crashlyticsUploadSymbolsRelease or ./gradlew crashlyticsUploadSymbolsDebug there should be a line like 'Successfully uploaded symbols'. I don't see this line after running the task and I don't see any errors (I've used --info and --debug). I've searched around for different kind of solutions suggested on other posts but nothing seems to work.

Versions

Is there anything else that needs to be done before uploading the symbols? Is there a way to check if they were uploaded successfully?

Thanks!

Upvotes: 1

Views: 2415

Answers (1)

Rene
Rene

Reputation: 127

When contacting the Crashlytics helpdesk I got some steps to provide them with some logs. While going through these steps everything just worked, the stacktraces are showing up in Crashlytics as expected.

In case someone runs into any problems. Check the crashlytics logs (Thanks for the helpdesk for providing these steps!):

Linux / Windows: ~/.crashlytics/com.crashlytics.tools/crashlytics.log

Mac: ~/Library/Caches/com.crashlytics/com.crashlytics.tools/crashlytics.log

  1. Delete crashlytics.log file
  2. Run symbol upload gradle task
  3. Build and run app, run into test crash

Check crashlytics.log, it should contain something like this:

[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.

EDIT: When trying to upload the release symbols I ran into the same problem. The stacktraces were not showing up. After doing a rebuilt of my project and another ./gradlew crashlyticsUploadSymbolsRelease everything worked.

EDIT2: Make sure you set this value to false in your gradle.properties

android.bundle.enableUncompressedNativeLibs=false

Upvotes: 2

Related Questions