Skip to content

unstrippedNativeLibsDir property can't accomodate build type and flavor variations together #1684

Closed

Description

@doganov

[READ] Step 1: Are you in the right place?

Issues filed here should be about bugs in the code in this repository.
If you have a general question, need help debugging, or fall into some
other category use one of these other channels:

  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general Firebase discussion, use the firebase-talk
    google group.
  • For help troubleshooting your application that does not fall under one
    of the above categories, reach out to the personalized
    Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: 3.6.3
  • Firebase Component: Crashlytics (Database, Firestore, Storage, Functions, etc)
  • Component version:
    firebase-crashlytics-ndk: 17.0.1
    firebase-crashlytics-plugin: 2.1.1

[REQUIRED] Step 3: Describe the problem

We have a fairly complex project layout, so the default Crashlytics heuristics for locating the unstripped binaries do not work for us. So we have to arrange the proper file tree ourselves and then point to it using the strippedNativeLibsDir and unstrippedNativeLibsDir properties. Of course, the binaries are different depending on the build flavor and the build type, so having a common value for those properties in the defaultConfig is a no-go. We can set those properties per build type, but then the per-flavor variation is lost. If we set them per-flavor, then the per-build type variation is lost.

Steps to reproduce:

android {

    // This setup assumes the same binaries are used for all flavors
    builtTypes {
        debug {
            firebaseCrashlytics {
                strippedNativeLibsDir 'myLibs/stripped/debug'
                unstrippedNativeLibsDir 'myLibs/unstripped/debug'
            }
        }
        release {
            firebaseCrashlytics {
                strippedNativeLibsDir 'myLibs/stripped/release'
                unstrippedNativeLibsDir 'myLibs/unstripped/release'
            }
        }
    }

    // This setup assumes the same binaries are used for all build types
    flavors {
        flavorA {
            firebaseCrashlytics {
                strippedNativeLibsDir 'myLibs/stripped/flavorA'
                unstrippedNativeLibsDir 'myLibs/unstripped/flavorA'
            }
        }
        flavorB {
            firebaseCrashlytics {
                strippedNativeLibsDir 'myLibs/stripped/flavorB'
                unstrippedNativeLibsDir 'myLibs/unstripped/flavorB'
            }
        }
    }
}

So one couldn't organize myLibs/stripped and myLibs/unstripped to hold AGP-like hierarchies with variant dirs inside. Either the build type or the flavor configuration "wins".

Relevant Code:

Ideally, the one would be able to set a "root" directory that contains variant-dir hierarchies

android {
    defaultConfig {
        firebaseCrashlytics {
            strippedNativeLibsRootDir 'myLibs/stripped'
            unstrippedNativeLibsRootDir 'myLibs/unstripped'
        }
    }
}

Or, alternatively, at least one should be able to set those properties for each variant:

android.applicationVariants.all { variant ->
    variant.firebaseCrashlytics.strippedNativeLibsDir "myLibs/stripped/${variant.dirName}"
    variant.firebaseCrashlytics.unstrippedNativeLibsDir "myLibs/unstripped/${variant.dirName}"
}

Unfortunately, the Firebase Crashlytics extension properties are not available in the variant, so the snippet above doesn't work.

Activity

  1. changed the title [-]unstrippedNativeLibsDir property can't accomodate build time and flavor variations together[/-] [+]unstrippedNativeLibsDir property can't accomodate build type and flavor variations together[/+] on Jun 18, 2020
  2. kevinkokomani commented on Jun 24, 2020

    @kevinkokomani

    Thanks for reporting this so thoroughly! Here's an issue reported a little while back that looks very similar: #1564. So it looks like this is a known issue, though I'm not sure when the team will be able to prioritize a fix.

  3. darrentaft commented on Nov 17, 2020

    @darrentaft

    I have a similar setup (as detailed in #1564) and have worked around it using an environment variable that I set before build and read in Gradle:

        def variantName = System.getenv('VARIANT_NAME')
    

    and then:

        strippedNativeLibsDir "build/intermediates/stripped_native_libs/$variantName/out/lib"
        unstrippedNativeLibsDir "build/intermediates/merged_native_libs/$variantName/out/lib"
    

    I can see that it's picking up the correct folder OK in the build output, but then it fails to find symbols in the files:

    [DEBUG] [com.google.firebase.crashlytics] Generating symbols for D:\mobile\ssd_android_tv\app\build\intermediates\merged_native_libs\SportSprintRelease\out\lib\x86_64\libnexplayerengine.so
    [DEBUG] [com.google.firebase.crashlytics] Using ELF data for cSYM generation.
    [DEBUG] [com.google.firebase.crashlytics] Crashlytics found no symbols for D:\mobile\ssd_android_tv\app\build\intermediates\merged_native_libs\SportSprintRelease\out\lib\x86_64\libnexplayerengine.so, skipping.
    

    I know that the symbols are in the files, as I'm also using:

    ndk {
        debugSymbolLevel = 'FULL'
    }
    

    and the app bundle I'm generating includes all the relevant .dbg files - Play Store is correctly showing full stack traces. It's only Crashlytics that can't get them, and is bundling ALL my NDK-related crashes under a single banner with a useless stack trace.

    Any ideas?

  4. ened commented on Jan 4, 2021

    @ened

    @kevinkokomani @TKBurner hi there, happy new year - is there a update on this issue in sight?

  5. st0rmr1der1994 commented on Aug 18, 2021

    @st0rmr1der1994

    I can also relate to this issue.
    Project has release/debug build types in combination with flavors for different app stores. I can't configure these variables dynamically to match flavor directory. Also, it will be nice to finally get rid of such code

    afterEvaluate {
            android.applicationVariants.all { variant ->
                if (variant.buildType.name != "debug") {
                    def variantName = variant.name.capitalize()
                    println("symbols will be added on variant ${variantName}")
    
                    def task = tasks.findByName("assemble${variantName}")
                    def uploader = "uploadCrashlyticsSymbolFile${variantName}"
    
                    // This triggers after task completion
                    task?.finalizedBy(uploader)
                }
            }
        }
    
  6. gildor commented on Sep 13, 2021

    @gildor

    It looks that to properly solve this issue we need the support of new androidComponents.onVariants (or `beforeVariant) API from AGP 7.0, so it would be possible to configure each variant Firebase properties separately, and do not work with tasks anymore

  7. ScottKitchell commented on Oct 6, 2021

    @ScottKitchell

    After some pain here, I've found another workaround.
    You can set the paths defined in the firebaseCrashlytics to the parent directory like @doganov suggested (rather than to each flavor+build sub-directory), but then you also have to add a dependency to the uploadCrashlyticsSymbolFile... tasks to delete any non-relevant variant files before uploading.

    android {
        defaultConfig {
            firebaseCrashlytics {
                nativeSymbolUploadEnabled true
                strippedNativeLibsDir 'myLibs/stripped'
                unstrippedNativeLibsDir 'myLibs/unstripped'
            }
        }
    
        productFlavors { 
            // any number of flavors and dimensions 
        }
    
        buildTypes {
            // ...
        }
        
        applicationVariants.all { variant ->
            tasks."uploadCrashlyticsSymbolFile${variant.name.capitalize()}".dependsOn {
                delete fileTree(dir: "myLibs/stripped", exclude: variant.name)
                delete fileTree(dir: "myLibs/unstripped", exclude: variant.name)
                println("Cleaned myLibs/stripped/ and myLibs/unstripped/")
            }
        }
    }
  8. mrichards commented on Dec 1, 2021

    @mrichards
    Contributor

    Hi folks, we just shipped version 2.8.1 of the Crashlytics Gradle plugin, which should (finally!) prioritize multi-dimensional flavor properties correctly.

    Thank you for your patience, and please re-open the issue if you continue to experience problems with firebaseCrashlytics properties when using multiple flavor & build type combinations.

  9. doganov commented on Dec 10, 2021

    @doganov
    Author

    I am sorry, but I do not see how multi-dimensional flavor priorities address the original issue I reported. The example code in the original report doesn't involve multi-dimensional flavors at all.

    I would like to re-open the issue as @mrichards suggests, but I don't seem to have permissions to do it as the issue was closed by a project contributor.

  10. gildor commented on Dec 13, 2021

    @gildor

    Completely agree, this doesn't solve the original issue. We need a way to configure different build variants with different crashlytics config

  11. locked and limited conversation to collaborators on Jan 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions