Skip to content

Commit 385ed2f

Browse files
authored
improved SDK values -use SDK Version values from root project
Instead of assuming the `compileSdkVersion `, `targetSdkVersion`, etc, we can make it dynamic by reading it from the root project. Android Target API Level 26 will be required in August 2018. https://android-developers.googleblog.com/2017/12/improving-app-security-and-performance.html Therefore I wrote target values of 26 instead of 23 And the React Native team is already working on this: facebook/react-native#18095 facebook/react-native#17741
1 parent b308231 commit 385ed2f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

android/build.gradle

+9-5
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ buildscript {
1111

1212
apply plugin: 'com.android.library'
1313

14+
def safeExtGet(prop, fallback) {
15+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
16+
}
17+
1418
android {
15-
compileSdkVersion 23
19+
compileSdkVersion safeExtGet('compileSdkVersion', 26)
1620
//noinspection GradleDependency
17-
buildToolsVersion "23.0.1"
21+
buildToolsVersion safeExtGet('buildToolsVersion', '26.0.3')
1822

1923
defaultConfig {
20-
minSdkVersion 16
24+
minSdkVersion safeExtGet('minSdkVersion', 16)
2125
//noinspection OldTargetApi
22-
targetSdkVersion 22
26+
targetSdkVersion safeExtGet('targetSdkVersion', 26)
2327
versionCode 1
2428
versionName "1.0"
2529
}
@@ -39,5 +43,5 @@ repositories {
3943

4044
dependencies {
4145
//noinspection GradleDynamicVersion
42-
compile 'com.facebook.react:react-native:+'
46+
compile "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
4347
}

0 commit comments

Comments
 (0)