Skip to content

Commit c570860

Browse files
authored
Android cleanup: little improved way of getting SDK values
just a little improved version rather then many explicit def for each value. hence, less cluttering. also made the react-native package to get the dynamic versions as well Android Target API Level 26 will be required in August 2018. https://android-developers.googleblog.com/2017/12/improving-app-security-and-performance.html I was going to write 26 but Since we are already using latest Gradle, Therefore I wrote target values of 27 instead of 25. And the React Native team is already working on this: facebook/react-native#18095 facebook/react-native#17741
1 parent c3b3802 commit c570860

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

lib/android/build.gradle

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
apply plugin: 'com.android.library'
22
apply from: 'gradle-maven-push.gradle'
33

4-
def DEFAULT_COMPILE_SDK_VERSION = 25
5-
def DEFAULT_BUILD_TOOLS_VERSION = "25.0.3"
6-
def DEFAULT_TARGET_SDK_VERSION = 25
7-
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "10.2.4"
8-
def DEFAULT_ANDROID_MAPS_UTILS_VERSION = "0.5+"
4+
def safeExtGet(prop, fallback) {
5+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
6+
}
97

108
android {
11-
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
12-
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
9+
compileSdkVersion safeExtGet('compileSdkVersion', 27)
10+
buildToolsVersion safeExtGet('buildToolsVersion', '27.0.3')
1311

1412
defaultConfig {
15-
minSdkVersion 16
16-
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
13+
minSdkVersion safeExtGet('minSdkVersion', 16)
14+
targetSdkVersion safeExtGet('targetSdkVersion', 27)
1715
}
1816

1917
packagingOptions {
@@ -40,10 +38,10 @@ android {
4038
}
4139

4240
dependencies {
43-
def googlePlayServicesVersion = rootProject.hasProperty('googlePlayServicesVersion') ? rootProject.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION
44-
def androidMapsUtilsVersion = rootProject.hasProperty('androidMapsUtilsVersion') ? rootProject.androidMapsUtilsVersion : DEFAULT_ANDROID_MAPS_UTILS_VERSION
41+
def googlePlayServicesVersion = safeExtGet('googlePlayServicesVersion', '10.2.4')
42+
def androidMapsUtilsVersion = safeExtGet('googlePlayServicesVersion', '0.5+')
4543

46-
compileOnly "com.facebook.react:react-native:+"
44+
compileOnly "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
4745
implementation "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
4846
implementation "com.google.android.gms:play-services-maps:$googlePlayServicesVersion"
4947
implementation "com.google.maps.android:android-maps-utils:$androidMapsUtilsVersion"

0 commit comments

Comments
 (0)