forked from organicmaps/organicmaps
[android]: Enable Firebase Crashlytics only for Beta builds
- Enable Google Mobile Services for all flavors except fdroid. - Enable Google Firebase Services for all beta builds flavors fdroid only if google-services.json exists We want to get all stars in εxodus privacy report. Signed-off-by: Roman Tsisyk <roman@tsisyk.com>
This commit is contained in:
parent
f19de9ad56
commit
bd8d89af23
7 changed files with 49 additions and 16 deletions
|
@ -5,19 +5,42 @@ buildscript {
|
|||
jcenter()
|
||||
}
|
||||
|
||||
ext.googleServiceEnabled = file('google-services.json').exists()
|
||||
if (googleServiceEnabled) {
|
||||
println("Building with Google Services")
|
||||
} else {
|
||||
println("Building without Google Services")
|
||||
}
|
||||
//
|
||||
// The magic below is needed to disable Google Mobile Services (a.k.a GMS) and
|
||||
// Google Firebase Services during the build time. Unfortunately, the only way
|
||||
// to disable Gradle plugins is to add these hardcore switches to buildscript().
|
||||
//
|
||||
|
||||
// Detect flavors from the task name.
|
||||
def isFdroid = getGradle().getStartParameter().getTaskRequests().toString().toLowerCase().contains("fdroid");
|
||||
def isBeta = getGradle().getStartParameter().getTaskRequests().toString().toLowerCase().contains("beta");
|
||||
|
||||
// Enable Google Mobile Services for all flavors except fdroid.
|
||||
def googleMobileServicesDefault = !isFdroid;
|
||||
// Add a parameter to force GMS.
|
||||
ext.googleMobileServicesEnabled = project.hasProperty('gms') ?: googleMobileServicesDefault;
|
||||
|
||||
// Enable Firebase for all beta flavors except fdroid only if google-services.json exists.
|
||||
def googleFirebaseServicesDefault = isBeta && !isFdroid && file('google-services.json').exists();
|
||||
// Add a parameter to force Firebase.
|
||||
ext.googleFirebaseServicesEnabled = project.hasProperty('firebase') ?: googleFirebaseServicesDefault;
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.2'
|
||||
if (googleServiceEnabled) {
|
||||
|
||||
if (googleMobileServicesEnabled) {
|
||||
println("Building with Google Mobile Services")
|
||||
classpath 'com.google.gms:google-services:4.3.5'
|
||||
} else {
|
||||
println("Building without Google Services")
|
||||
}
|
||||
|
||||
if (googleFirebaseServicesEnabled) {
|
||||
println("Building with Google Firebase Services")
|
||||
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.1'
|
||||
classpath 'com.google.firebase:firebase-appdistribution-gradle:2.1.0'
|
||||
} else {
|
||||
println("Building without Google Firebase Services")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,8 +68,10 @@ repositories {
|
|||
|
||||
apply plugin: 'com.android.application'
|
||||
apply from: 'secure.properties'
|
||||
if (googleServiceEnabled) {
|
||||
if (googleMobileServicesEnabled) {
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
}
|
||||
if (googleFirebaseServicesEnabled) {
|
||||
apply plugin: 'com.google.firebase.crashlytics'
|
||||
apply plugin: 'com.google.firebase.appdistribution'
|
||||
}
|
||||
|
@ -57,10 +82,13 @@ dependencies {
|
|||
|
||||
implementation 'androidx.multidex:multidex:' + propMultiDexVersion
|
||||
|
||||
// Google Services
|
||||
if (googleServiceEnabled) {
|
||||
// Google Mobile Services
|
||||
if (googleMobileServicesEnabled) {
|
||||
implementation 'com.google.android.gms:play-services-location:17.0.0'
|
||||
implementation 'com.google.firebase:firebase-analytics:17.4.4'
|
||||
}
|
||||
|
||||
// Google Firebase Services
|
||||
if (googleFirebaseServicesEnabled) {
|
||||
implementation 'com.google.firebase:firebase-crashlytics:17.1.1'
|
||||
implementation 'com.google.firebase:firebase-crashlytics-ndk:17.1.1'
|
||||
}
|
||||
|
@ -227,10 +255,15 @@ android {
|
|||
manifest.srcFile 'AndroidManifest.xml'
|
||||
res.srcDirs = ['res']
|
||||
java.srcDirs = ['src']
|
||||
if (googleServiceEnabled) {
|
||||
java.srcDirs += 'flavors/google-services-enabled'
|
||||
if (googleMobileServicesEnabled) {
|
||||
java.srcDirs += 'flavors/gms-enabled'
|
||||
} else {
|
||||
java.srcDirs += 'flavors/google-services-disabled'
|
||||
java.srcDirs += 'flavors/gms-disabled'
|
||||
}
|
||||
if (googleFirebaseServicesEnabled) {
|
||||
java.srcDirs += 'flavors/firebase-enabled'
|
||||
} else {
|
||||
java.srcDirs += 'flavors/firebase-disabled'
|
||||
}
|
||||
|
||||
// assets folder is auto-generated by tools/android/update_assets.sh, so we keep all static resources in separate folders.
|
||||
|
@ -456,7 +489,7 @@ android {
|
|||
resValue 'string', 'app_id', android.defaultConfig.applicationId
|
||||
resValue 'string', 'app_name', project.ext.appName
|
||||
ndk.debugSymbolLevel = 'SYMBOL_TABLE'
|
||||
if (googleServiceEnabled) {
|
||||
if (googleFirebaseServicesEnabled) {
|
||||
firebaseCrashlytics {
|
||||
nativeSymbolUploadEnabled true
|
||||
}
|
||||
|
@ -471,7 +504,7 @@ android {
|
|||
resValue 'string', 'app_id', android.defaultConfig.applicationId + applicationIdSuffix
|
||||
resValue 'string', 'app_name', project.ext.appName + applicationIdSuffix
|
||||
ndk.debugSymbolLevel = 'SYMBOL_TABLE'
|
||||
if (googleServiceEnabled) {
|
||||
if (googleFirebaseServicesEnabled) {
|
||||
firebaseCrashlytics {
|
||||
nativeSymbolUploadEnabled true
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue