12

Am trying out the recently released feature that allows uploading of ProGuard mapping file to Firebase (https://firebase.google.com/docs/crash/android) using gradle task. The following is the task I'm running.

./gradlew -PFirebaseServiceAccountFilePath=xxxxx.json :app:firebaseUploadReleaseProguardMapping

However, it doesn't seem to be recognizing service account file. Has anyone had any luck getting this working? I've also tried defining FirebaseServiceAccountFilePath in gradle.properties.

* What went wrong:
Execution failed for task ':app:firebaseUploadReleaseProguardMapping'.
> Service account file path has not been defined! Service accounts are used to authorize your mapping file uploads.  Learn more at
  https://firebase.google.com/docs/crash/android.
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
John O'Reilly
  • 10,000
  • 4
  • 41
  • 63

3 Answers3

24

Set relative path to json in gradle.properties (in project root)

FirebaseServiceAccountFilePath = /firebase-crashreporting.json

and update this property in your build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-crash'

android {
    ...
}

setProperty("FirebaseServiceAccountFilePath", rootProject.rootDir.absolutePath + FirebaseServiceAccountFilePath)

dependencies {
    ...
}
OlegKrikun
  • 645
  • 5
  • 10
5

The error message is misleading. You will see that if the file path that you give for the service account wasn't found. Try passing the full, unambiguous path of the service account file (try not to depend on relative paths).

I'll make sure that the next version of the plugin has a more meaningful error message for the case where the file isn't found. Sorry about the trouble.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • Thanks Doug. Using full path got me past that issue. The next error I'm getting is FileNotFoundException: /google-services.json". I guess it makes sense that there'd be dependency on `google-services.json` (for various reasons we're using `FirebaseApp.initializeApp()` to init firebase rather than depending on existence of that file) – John O'Reilly Dec 17 '16 at 18:20
  • Got it. That's a completely different problem. I'll have to file a different issue to let you pass the project id through the command line as well. For now, you could try to download your project's google-services.json file and put it in the expected place just so the plugin can get a hold of what it needs in order to perform the upload. – Doug Stevenson Dec 17 '16 at 18:45
  • The issue we have with doing that is that same code/build is used to build a (dynamic) number of different apps. – John O'Reilly Dec 17 '16 at 18:46
  • Ah, yeah, I was just writing that case into the bug report. but yeah, my proposed workaround won't be easy for you, as you'd have to copy a new file into place for each variant, and run them all individually. – Doug Stevenson Dec 17 '16 at 18:57
  • For what it is worth, I used a relative path. Relative to the `app` module directory and not the project directory. – Knossos Jan 06 '17 at 09:00
  • This is a great feature, I introduced this to my team a while back and was very jealous of the fact that iOS symbols were uploaded automatically and we would have to upload them manually :) but I would love to be able to use a relative path for the service account file, we have multiple release managers and having each one of them define the file path differently would be a hassle. – Muhammad Alfaifi Jan 12 '17 at 21:02
  • @DougStevenson I'm also getting FileNotFoundException (since i have different google.json for debug and release). I understand your proposed solution, but is this solved yet? Can I pass google.json as an argument in console? – VizGhar Jan 14 '17 at 16:52
  • @DougStevenson what specific fields in `google-services.json` does the plugin need access to (thinking in the case I described above where there's multiple apps.....if perhaps we can dynamically update that particular field in the file before running the task)? – John O'Reilly Jan 21 '17 at 20:49
  • @JohnO'Reilly You should be able to figure out what you need from this documentation: https://developers.google.com/android/guides/google-services-plugin The contents of the final resources are what matter the most. – Doug Stevenson Jan 21 '17 at 21:03
0

In my case I was using Jenkins to upload the proguard mappings for me. I had to change the file permissions for the json private key file from 400 to 444.

Mark Pazon
  • 6,167
  • 2
  • 34
  • 50