From 70be7128d04c840d840f5fcd01f2f56f8e0842c9 Mon Sep 17 00:00:00 2001 From: PeratX <1215714524@qq.com> Date: Mon, 15 Jul 2019 17:42:45 +0800 Subject: [PATCH] gradle: add pure productFlavor which contains no google libs --- .travis.yml | 2 +- app/build.gradle | 27 +++++++++++++++++-- app/src/debug/google-services.json | 42 ------------------------------ build.gradle | 3 --- 4 files changed, 26 insertions(+), 48 deletions(-) delete mode 100644 app/src/debug/google-services.json diff --git a/.travis.yml b/.travis.yml index 2b40e65..0420c20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,6 @@ android: - '.+' script: - chmod 777 gradlew - - ./gradlew clean assembleDebug + - ./gradlew clean assemblePureDebug after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/app/build.gradle b/app/build.gradle index c74d6a4..0a59f11 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,6 +22,15 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + flavorDimensions "default" + productFlavors { + pure { + dimension "default" + } + google { + dimension "default" + } + } lintOptions { checkReleaseBuilds false abortOnError false @@ -37,6 +46,10 @@ android { } } +configurations { + googleReleaseImplementation +} + dependencies { //Support implementation 'androidx.appcompat:appcompat:1.1.0-rc01' @@ -51,9 +64,19 @@ dependencies { implementation 'org.minidns:minidns-client:0.3.4' implementation 'com.google.code.gson:gson:2.8.5' implementation 'com.squareup.okhttp3:okhttp:3.14.1' + //Analytics - implementation 'com.google.firebase:firebase-core:17.0.1' - implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' + googleReleaseImplementation 'com.google.firebase:firebase-core:17.0.1' + googleReleaseImplementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' } apply plugin: 'com.google.gms.google-services' + +android.applicationVariants.all { variant -> + project.tasks.each { t -> + if (!t.name.toLowerCase().contains("googlerelease") && + (t.name.contains("GoogleServices") || t.name.contains("fabric"))) { + t.enabled = false + } + } +} diff --git a/app/src/debug/google-services.json b/app/src/debug/google-services.json deleted file mode 100644 index 4a25329..0000000 --- a/app/src/debug/google-services.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "project_info": { - "project_number": "364359664562", - "firebase_url": "https://daedalusdebug.firebaseio.com", - "project_id": "daedalusdebug", - "storage_bucket": "daedalusdebug.appspot.com" - }, - "client": [ - { - "client_info": { - "mobilesdk_app_id": "1:364359664562:android:51675184b44f9aaf", - "android_client_info": { - "package_name": "org.itxtech.daedalus" - } - }, - "oauth_client": [ - { - "client_id": "364359664562-oukpc6t0mjpgc4jqcmpe5qu4ghf6qjln.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyAq3BS019g5WXKll6ytod_DOszz3ISX4wY" - } - ], - "services": { - "analytics_service": { - "status": 1 - }, - "appinvite_service": { - "status": 1, - "other_platform_oauth_client": [] - }, - "ads_service": { - "status": 2 - } - } - } - ], - "configuration_version": "1" -} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 85e81ab..49925bf 100644 --- a/build.gradle +++ b/build.gradle @@ -12,9 +12,6 @@ buildscript { classpath 'com.android.tools.build:gradle:3.4.2' classpath 'com.google.gms:google-services:4.3.0' classpath 'io.fabric.tools:gradle:1.28.1' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files } }