Gradle build failed when .xml used instead google_services.json

Viewed 249

I'm setting up Firebase Crashlytics. It works OK when I use google_services.json. But as we have several build variants, I prefer to use .xml instead, so I could make 2 applications at console, and 2 files in project:

-src/main/res/values/google_services.xml (for all builds, corresponds to test app at firebase)
-src/release/res/values/google_services.xml (for prod-release build)

Also I removed apply plugin: 'com.google.gms.google-services'

But my builds fails for all release tasks:

assembleTestRelease
assembleStageRelease

Reason is in

minifyEnabled true
shrinkResources true

Before migration on Firebase Crashlytic (with Fabric) it worked fine.

Error:

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:uploadCrashlyticsMappingFileTestRelease'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:151)
    ...
Caused by: org.gradle.api.GradleException: Crashlytics could not find the resource file generated by Google Services. You may need to execute the :process<Variant>GoogleServices Task. Please check your Firebase project configuration (https://firebase.google.com/docs/android/setup). 
    at com.google.firebase.crashlytics.buildtools.gradle.ProjectVariantState.getGoogleAppId(ProjectVariantState.groovy:195)
    ... 35 more
1 Answers

You should be able to successfully recreate the google services xml files using these values:

google_app_id:

{YOUR_CLIENT}/client_info/mobilesdk_app_id

gcm_defaultSenderId:

project_info/project_number

default_web_client_id:

{YOUR_CLIENT}/oauth_client/client_id (client_type == 3)

ga_trackingId:

{YOUR_CLIENT}/services/analytics-service/analytics_property/tracking_id

firebase_database_url:

project_info/firebase_url

google_api_key:

{YOUR_CLIENT}/api_key/current_key

google_crash_reporting_api_key:

{YOUR_CLIENT}/api_key/current_key

project_id:

project_info/project_id
Related