Skip to content

Commit 3dcd804

Browse files
author
James Pearson
committed
Allow the override of compileSdkVersion, buildToolsVersion, minSdkVersion and targetSdkVersion
1 parent c7e933c commit 3dcd804

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

android/build.gradle

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
apply plugin: 'com.android.library'
22

3-
def DEFAULT_COMPILE_SDK_VERSION = 26
4-
def DEFAULT_BUILD_TOOLS_VERSION = "26.0.2"
3+
4+
def safeExtGet(prop, fallback) {
5+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
6+
}
7+
58
def DEFAULT_TARGET_SDK_VERSION = 26
69

710
android {
8-
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
9-
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
11+
compileSdkVersion safeExtGet("compileSdkVersion", 23)
12+
buildToolsVersion safeExtGet("buildToolsVersion", "23.0.1")
13+
1014

1115
defaultConfig {
12-
minSdkVersion 16
13-
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
16+
minSdkVersion safeExtGet("minSdkVersion", 16)
17+
targetSdkVersion safeExtGet("targetSdkVersion", 23)
1418
versionCode 1
1519
versionName "1.0"
1620
ndk {
@@ -21,4 +25,4 @@ android {
2125

2226
dependencies {
2327
compileOnly 'com.facebook.react:react-native:+'
24-
}
28+
}

0 commit comments

Comments
 (0)