Search code examples
androidfirebaseandroid-proguardfirebase-crash-reporting

Define FirebaseServiceAccountFilePath dynamically for build variants


I have an Android project using two firebase instances per build variant (e.g. staging -> Firebase Project 1 and release -> Firebase Project 2). I'd like to be able to upload the mapping.txt whenever I invoke assemble so the crashes would be deobfuscated. Is there a way to dynamically set FirebaseServiceAccountFilePath property for each build variant? Thanks


Solution

  • Currently, you will have to invoke two different builds on the command line with the two different paths for your service account. So, something like this, if you have variants foo and bar:

    ./gradlew -PFirebaseServiceAccountFilePath=/path/to/foo.json firebaseUploadFooReleaseProguardMapping 
    ./gradlew -PFirebaseServiceAccountFilePath=/path/to/bar.json firebaseUploadBarReleaseProguardMapping 
    

    There isn't currently a way to specify a different service account for both builds in a single invocation. However, if both variants use the same mapping, you can upload them both in the same invocation.