Skip to content

Commit ee38041

Browse files
committed
android: refine build.gradle get versions
Use the same method in https://github.com/oney/react-native-webrtc/pull/494/files credit: [@maxhawkins](https://github.com/maxhawkins) And keep fallback version as default.
1 parent 0d59b74 commit ee38041

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

android/build.gradle

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

3-
def _ext = rootProject.ext
4-
5-
def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion : 27
6-
def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '27.0.3'
7-
def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 16
8-
def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 27
3+
def safeExtGet(prop, fallback) {
4+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
5+
}
96

107
android {
11-
compileSdkVersion _compileSdkVersion
12-
buildToolsVersion _buildToolsVersion
8+
compileSdkVersion safeExtGet('compileSdkVersion', 23)
9+
buildToolsVersion safeExtGet('buildToolsVersion', "23.0.1")
1310

1411
defaultConfig {
15-
minSdkVersion _minSdkVersion
16-
targetSdkVersion _targetSdkVersion
12+
minSdkVersion safeExtGet('minSdkVersion', 16)
13+
targetSdkVersion safeExtGet('targetSdkVersion', 22)
1714
versionCode 1
1815
versionName "1.0"
1916
}

0 commit comments

Comments
 (0)