添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account
  • Android Studio version: 4.1.0-rc03
  • Firebase Component: Crashlytics Gradle Plugin
  • Component version: 2.3.0
  • Describe the problem

    There are two issues which I believe are caused by the same underlying issue which is that the Firebase Gradle Plugin looks for the NDK tasks before they are actually created.

    The first issue is that you have to manually specify the strip tasks like so:

    android.buildTypes.all {
        if (firebaseCrashlytics.nativeSymbolUploadEnabled) {
            firebaseCrashlytics {
                unstrippedNativeLibsDir = "build/intermediates/merged_native_libs/$name/out/lib/"
                strippedNativeLibsDir = "build/intermediates/stripped_native_libs/$name/out/lib/"
    

    without these you get an error saying:

    org.gradle.api.GradleException: Crashlytics could not determine stripped/unstripped native library directories for project ':app', variant Release. These are required for generating symbol files when NDK build tasks cannot be automatically inferred. Please specify strippedNativeLibsDir and unstrippedNativeLibsDir in the firebaseCrashlytics extension.
    

    But even if this is added you get a warning saying (and no symbols are uploaded):

    Crashlytics could not find NDK build tasks on which to depend. You many need to manually enforce task dependencies for generateCrashlyticsSymbolFileRelease
    

    Steps to reproduce:

    See this attached project: TestCrashlyticsGradle.zip

    Workaround

    In my project I've added this to my app/build.gradle.kts to fix the issue (Kotlin DSL):

    android.buildTypes.all {
        // We need to do `== true` because it's `null` by default
        if (firebaseCrashlytics.nativeSymbolUploadEnabled == true) {
            firebaseCrashlytics {
                unstrippedNativeLibsDir = "build/intermediates/merged_native_libs/$name/out/lib/"
                strippedNativeLibsDir = "build/intermediates/stripped_native_libs/$name/out/lib/"
    // Make the generate symbol task depend on the strip task
    tasks.withType<GenerateSymbolFileTask> {
        // Ideally we could set the directories here as the input and output of the strip task but
        // we get an error unless we set them in the `firebaseCrashlytics` extension  
        dependsOn("strip${name.removePrefix("generateCrashlyticsSymbolFile")}DebugSymbols")
    // Make the upload task depend on the generate task and hook up the inputs correctly
    tasks.withType<UploadSymbolFileTask> {
        val generateTask = tasks.getByName<GenerateSymbolFileTask>("generateCrashlyticsSymbolFile${name.removePrefix("uploadCrashlyticsSymbolFile")}")
        dependsOn(generateTask)
        symbolFileDir.set(generateTask.symbolFileOutputDir)
    // Lastly make the mappings upload depend on the symbols upload
    tasks.withType<UploadMappingFileTask> {
        dependsOn("uploadCrashlyticsSymbolFile${name.removePrefix("uploadCrashlyticsMappingFile")}")
              

    I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.
  • com.google.firebase:firebase-crashlytics-ndk:17.3.0
  • com.google.firebase:firebase-crashlytics-gradle:2.4.1
  • com.android.tools.build:gradle:4.1.1
  • gradle 6.7.1
  • In the crashlytics gradle plugin 2.4.0 release notes, it says:
    strippedNativeLibsDir defined in the firebaseCrashlytics extension is no longer necessary and will be removed in a future release.

    However, using 2.4.1, if I remove strippedNativeLibsDir and run ./gradlew clean assembleRelease uploadCrashlyticsSymbolFileRelease, I get:

    A problem occurred configuring project ':app'.
    > Failed to notify project evaluation listener.
       > org.gradle.api.GradleException: Crashlytics could not determine stripped/unstripped native library directories for project ':app', variant Debug. These are required for generating symbol files when NDK build tasks cannot be automatically inferred. Please specify strippedNativeLibsDir and unstrippedNativeLibsDir in the firebaseCrashlytics extension.
       > Task with name 'generateCrashlyticsSymbolFileDebug' not found in project ':app'.
    

    If I keep strippedNativeLibsDir, it works fine.