From 238927ab66413354e3fe8d38fdb9e16f3085195d Mon Sep 17 00:00:00 2001 From: Danish Date: Tue, 24 Jul 2018 16:39:26 +0300 Subject: [PATCH] little improvement over too many "def" just added a function which does acts like a ternary with fallback option. Hence, less cluttered "def" variables additionally, changes the SDK values from 23 to 26 as per new changes from react-native and Android Android Target API Level 26 will be required in August 2018. https://android-developers.googleblog.com/2017/12/improving-app-security-and-performance.html And the React Native team is already working on this: facebook/react-native#18095 facebook/react-native#17741 --- android/build.gradle | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 3c98bc229..ffdb7a461 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -9,24 +9,19 @@ buildscript { apply plugin: 'com.android.library' -def _ext = rootProject.ext +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} -def _reactNativeVersion = _ext.has('reactNative') ? _ext.reactNative : '+' -def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion : 23 -def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '23.0.1' -def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 16 -def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 22 -def _glideVersion = _ext.has('glideVersion') ? _ext.glideVersion : '4.7.1' -def _excludeAppGlideModule = _ext.has('excludeAppGlideModule') ? _ext.excludeAppGlideModule : false android { - compileSdkVersion _compileSdkVersion - buildToolsVersion _buildToolsVersion + compileSdkVersion safeExtGet('compileSdkVersion', 26) + buildToolsVersion safeExtGet('buildToolsVersion', '26.0.3') sourceSets { main { java { - if (_excludeAppGlideModule) { + if (safeExtGet('excludeAppGlideModule', false)) { srcDir 'src' exclude '**/FastImageGlideModule.java' } @@ -35,8 +30,8 @@ android { } defaultConfig { - minSdkVersion _minSdkVersion - targetSdkVersion _targetSdkVersion + minSdkVersion safeExtGet('minSdkVersion', 16) + targetSdkVersion safeExtGet('targetSdkVersion', 26) versionCode 1 versionName "1.0" } @@ -54,16 +49,16 @@ repositories { dependencies { //noinspection GradleDynamicVersion - compile "com.facebook.react:react-native:${_reactNativeVersion}" - compile "com.android.support:support-v4:${_compileSdkVersion}" - compile("com.github.bumptech.glide:glide:${_glideVersion}") { + compile "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}" + compile "com.android.support:support-v4:${safeExtGet('compileSdkVersion', 26)}" + compile("com.github.bumptech.glide:glide:${safeExtGet('glideVersion', 4.7.1)}") { exclude group: "com.android.support" } - compile("com.github.bumptech.glide:annotations:${_glideVersion}") { + compile("com.github.bumptech.glide:annotations:${safeExtGet('glideVersion', 4.7.1)}") { exclude group: "com.android.support" } - annotationProcessor "com.github.bumptech.glide:compiler:${_glideVersion}" - compile("com.github.bumptech.glide:okhttp3-integration:${_glideVersion}") { + annotationProcessor "com.github.bumptech.glide:compiler:${safeExtGet('glideVersion', 4.7.1)}" + compile("com.github.bumptech.glide:okhttp3-integration:${safeExtGet('glideVersion', 4.7.1)}") { exclude group: "com.android.support" exclude group: 'glide-parent' }