From d80d8a4d42d260ce7fe89f622244ebb3a498bfc5 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Mon, 10 Sep 2018 15:58:36 +0300 Subject: [PATCH] Ensure correct google-services.json is supplied when building release APKs --- app/build.gradle | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 00e58bbd..5baea52e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,7 +1,8 @@ +import groovy.json.JsonSlurper + apply plugin: 'com.android.application' apply plugin: 'io.fabric' - android { compileSdkVersion 27 @@ -34,6 +35,17 @@ android { } } +tasks.whenTaskAdded { task -> + if (task.name.contains("assembleRelease")) { + task.getDependsOn().add({ + def inputFile = new File("app/google-services.json") + def json = new JsonSlurper().parseText(inputFile.text) + if(json.project_info.project_id != "mthmmy-release-3aef0") + throw new GradleException('Please supply the correct google-services.json for release or manually change the id above!') + }) + } +} + dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:27.1.1' @@ -44,7 +56,7 @@ dependencies { implementation 'com.android.support:cardview-v7:27.1.1' implementation 'com.android.support:recyclerview-v7:27.1.1' implementation 'com.google.firebase:firebase-core:16.0.3' - implementation 'com.google.firebase:firebase-messaging:17.3.0' + implementation 'com.google.firebase:firebase-messaging:17.3.1' implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5' implementation 'com.squareup.okhttp3:okhttp:3.10.0' implementation 'com.squareup.picasso:picasso:2.5.2'