6

I am trying to follow this documentation tutorial by Firebase to setup Android Studio to automatically send my ProGuard mappings file when building a release APK for my Android application.

However, I couldn't seem to understand steps 4 and 5 in the "Uploading ProGuard mapping files with Gradle" part, mainly because I didn't find any gradle.properties file in my project root or home path and because I wish to automate the execution of the app:firebaseUploadReleaseProguardMapping task in Android Studio, which I don't know how to do.

This is the contents of the gradle.properties file I've created in my project root directory:

FirebaseServiceAccountFilePath = /app/firebase-crash-reporting.json 

The firebase-crash-reporting.json file is my Firebase crash reporting private key. My mappings file is generated in the /app/build/outputs/mapping/release/ directory, if that helps.

Please assist me in completing those 2 steps and automatizing the process in Android Studio.

2 Answers 2

5

Just add

afterEvaluate { assembleRelease.doLast { firebaseUploadReleaseProguardMapping.execute() } } 

In the android section of build.gradle file.

This will automatically upload the ProGuard mappings file to Firebase as well as run/deploy the APK to the device using ADB.

Sign up to request clarification or add additional context in comments.

3 Comments

Error:(87, 1) Execution failed for task ':hotelsclick:assembleRelease'. > Could not get unknown property 'firebaseUploadReleaseProguardMapping' for task ':hotelsclick:assembleRelease' of type org.gradle.api.DefaultTask. It seems to me like the script doesn't know where to get the firebaseUploadReleaseProguardMapping property. And I don't know it either... -.-
@MarcoZanetti have you added compile 'com.google.firebase:firebase-crash:10.2.4' in your build.gradle ?
Yes @vipul-asri :-)
1

gradle.properties is owned and managed completely by you. You have to create it if it doesn't already exist. This means you should probably read the Gradle documentation on it to best understand how it provides properties to your builds, and which location is best for your properties.

You are not even obliged to use gradle.properties. You can also specify all the properties for the Crash Reporting plugin via the command line.

When you specify a path for the service account file, you should specify the full, unambiguous path to the file. In your example, it looks like you're assuming that it will look under the app directory in your project. If you want to do that, you still have to give the full path to the file.

5 Comments

Thanks, I have fixed my gradle.properties file, it now includes the full path to the private key JSON file. However, I'm not sure how to make Android Studio run "app:firebaseUploadReleaseProguardMapping" after "assembleRelease" properly, I tried creating a Gradle build config that runs "app" config then firebaseRelease task, but it fails with a "No task to execute is specified" error, I'd appreciate help regarding that.
The task that uploads the mapping will build your APK first. You can see that in the list of tasks it executes.
That works perfectly, I can see a new mapping file uploaded to my Firebase dashboard for this version, but this script doesn't deploy the APK to my device via ADB when building using the "Run" or "Debug" option, is there something I can add to make it deploy the APK it built? Thanks very much.
Run the appropriate install task with Gradle.
@AchrafAlmouloudi Hello. I've the same challenge like you. Could you paste the code which is in gradle.properties? I'm not sure what I have to change or add to this file to work properly with crash reporting. Thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.