Skip to content

Commit 3f1eb3c

Browse files
ajmathfathyb
authored andcommitted
fix(android): pull android tool versions from root project (#12)
If the host react native application is using a different version of the android sdk build tools, build warnings will be displayed about incompatibilities. This addresses that by using the values defined in the root project. This is the approach used by the current [react-native-create-library template](https://github.com/frostney/react-native-create-library/blob/master/templates/android.js#L28).
1 parent 7f1985d commit 3f1eb3c

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

packages/core/android/build.gradle

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ buildscript {
1212
}
1313
}
1414

15+
def safeExtGet(prop, fallback) {
16+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
17+
}
18+
1519
android {
16-
compileSdkVersion 26
17-
buildToolsVersion = '26.0.3'
20+
compileSdkVersion safeExtGet('compileSdkVersion', 26)
21+
buildToolsVersion safeExtGet('buildToolsVersion', '26.0.3')
1822

1923
defaultConfig {
20-
minSdkVersion 16
21-
targetSdkVersion 26
24+
minSdkVersion safeExtGet('minSdkVersion', 16)
25+
targetSdkVersion safeExtGet('targetSdkVersion', 26)
2226
versionCode 1
2327
versionName '1.0'
2428
}

packages/integrations/template/android/build.gradle

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ buildscript {
1212
}
1313
}
1414

15+
def safeExtGet(prop, fallback) {
16+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
17+
}
18+
1519
android {
16-
compileSdkVersion 26
20+
compileSdkVersion safeExtGet('compileSdkVersion', 26)
1721

1822
defaultConfig {
19-
minSdkVersion 16
20-
targetSdkVersion 26
23+
minSdkVersion safeExtGet('minSdkVersion', 16)
24+
targetSdkVersion safeExtGet('targetSdkVersion', 26)
2125
versionCode 1
2226
versionName '1.0'
2327

0 commit comments

Comments
 (0)