From 69267052a55dd95351e0805e735742c4333bd9ab Mon Sep 17 00:00:00 2001 From: Carlos Q Date: Thu, 19 Jul 2018 19:22:08 +0200 Subject: [PATCH 1/4] Use project-wide properties --- android/build.gradle | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 7872731..15966c0 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -12,13 +12,19 @@ buildscript { apply plugin: 'com.android.library' +def DEFAULT_COMPILE_SDK_VERSION = 27 +def DEFAULT_BUILD_TOOLS_VERSION = "27.0.3" +def DEFAULT_TARGET_SDK_VERSION = 27 +def DEFAULT_MIN_SDK_VERSION = 16 +def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "15.0.1" + android { - compileSdkVersion 27 - buildToolsVersion "27.0.3" + compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION + buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION - defaultConfig { - minSdkVersion 16 - targetSdkVersion 27 + defaultConfig { + minSdkVersion rootProject.hasProperty('minSdkVersion') ? rootProject.minSdkVersion : DEFAULT_MIN_SDK_VERSION + targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION versionCode 3 versionName "1.2" ndk { @@ -30,8 +36,10 @@ android { } } +def googlePlayServicesVersion = rootProject.hasProperty('googlePlayServicesVersion') ? rootProject.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION dependencies { api fileTree(include: ['*.jar'], dir: 'libs') api 'com.facebook.react:react-native:+' - api 'com.google.android.gms:play-services-location:15.0.1' + api "com.google.android.gms:play-services-location:$googlePlayServicesVersion" } + From 47b1119846d2fea6fbf6d1a2f9f8221e19012364 Mon Sep 17 00:00:00 2001 From: Carlos Q Date: Fri, 20 Jul 2018 00:25:42 +0200 Subject: [PATCH 2/4] Refactor --- android/build.gradle | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 15966c0..233107a 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,3 +1,7 @@ +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} + buildscript { repositories { mavenCentral() @@ -12,19 +16,13 @@ buildscript { apply plugin: 'com.android.library' -def DEFAULT_COMPILE_SDK_VERSION = 27 -def DEFAULT_BUILD_TOOLS_VERSION = "27.0.3" -def DEFAULT_TARGET_SDK_VERSION = 27 -def DEFAULT_MIN_SDK_VERSION = 16 -def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "15.0.1" - android { - compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION - buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION + compileSdkVersion safeExtGet('compileSdkVersion', 27) + buildToolsVersion safeExtGet('buildToolsVersion', '27.0.3') defaultConfig { - minSdkVersion rootProject.hasProperty('minSdkVersion') ? rootProject.minSdkVersion : DEFAULT_MIN_SDK_VERSION - targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION + minSdkVersion safeExtGet('minSdkVersion', 16) + targetSdkVersion safeExtGet('targetSdkVersion', 27) versionCode 3 versionName "1.2" ndk { @@ -36,10 +34,10 @@ android { } } -def googlePlayServicesVersion = rootProject.hasProperty('googlePlayServicesVersion') ? rootProject.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION + dependencies { api fileTree(include: ['*.jar'], dir: 'libs') api 'com.facebook.react:react-native:+' - api "com.google.android.gms:play-services-location:$googlePlayServicesVersion" + api "com.google.android.gms:play-services-location:${safeExtGet('googlePlayServicesVersion', '27.0.2')}" } From dc905cc8d029091ea58af3dcd0820aef74036be8 Mon Sep 17 00:00:00 2001 From: Carlos Q Date: Fri, 20 Jul 2018 13:04:23 +0200 Subject: [PATCH 3/4] Fix google play version --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 233107a..4064529 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -38,6 +38,6 @@ android { dependencies { api fileTree(include: ['*.jar'], dir: 'libs') api 'com.facebook.react:react-native:+' - api "com.google.android.gms:play-services-location:${safeExtGet('googlePlayServicesVersion', '27.0.2')}" + api "com.google.android.gms:play-services-location:${safeExtGet('googlePlayServicesVersion', '15.0.1')}" } From 46e7dd849af968b814455fb8a5af818794db209f Mon Sep 17 00:00:00 2001 From: Carlos Q Date: Fri, 20 Jul 2018 13:06:38 +0200 Subject: [PATCH 4/4] Use project-wide properties --- samples/LocationEnable/android/build.gradle | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/samples/LocationEnable/android/build.gradle b/samples/LocationEnable/android/build.gradle index 4de96ac..b018028 100644 --- a/samples/LocationEnable/android/build.gradle +++ b/samples/LocationEnable/android/build.gradle @@ -24,3 +24,11 @@ allprojects { google() } } +ext { + buildToolsVersion = "27.0.3" + minSdkVersion = 16 + compileSdkVersion = 27 + targetSdkVersion = 27 + supportLibVersion = "27.1.1" + googlePlayServicesVersion = "15.0.1" +}