From a4c9729508ea2a5331117fc0891330e81e1a46f8 Mon Sep 17 00:00:00 2001 From: William Swanson Date: Fri, 19 Apr 2019 13:37:40 -0700 Subject: [PATCH] Become compatible with React Native v0.59 React Native v0.59 uses a new version of the Android SDK that is incompatible with the one in this library, producing build failures. Using the `rootProject` setting means this library will automatically work with a broad range of React Native versions, so this shouldn't be a breaking change. --- android/build.gradle | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 849e79a..e8df4bf 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -11,13 +11,22 @@ buildscript { apply plugin: 'com.android.library' +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} + +def DEFAULT_COMPILE_SDK_VERSION = 26 +def DEFAULT_BUILD_TOOLS_VERSION = "26.0.3" +def DEFAULT_MIN_SDK_VERSION = 16 +def DEFAULT_TARGET_SDK_VERSION = 22 + android { - compileSdkVersion 26 - buildToolsVersion "26.0.3" + compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION) + buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION) defaultConfig { - minSdkVersion 16 - targetSdkVersion 22 + minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION) + targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION) versionCode 1 versionName "1.0" }