浏览代码

improvement way to get root SDK versions

just added a function which acts like a ternary with fallback option. Hence, less cluttered "def" variables  
additionally, changed the SDK values from 23 to 26 as per new changes from react-native and Android

Android Target API Level 26 will be required in August 2018.
https://android-developers.googleblog.com/2017/12/improving-app-security-and-performance.html

And the React Native team is already working on this:
facebook/react-native#18095
facebook/react-native#17741

PS: I am aware of this PR https://github.com/joltup/rn-fetch-blob/pull/128 but first its still targeting old SDK values i.e 23 as fallback and secondly I am not sure of the use of `project` to get the value instead of proper way i.e `rootProject.ext` to get the property value.
Danish 6 年前
父节点
当前提交
a4abef9c36
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 9 次插入5 次删除
  1. 9
    5
      android/build.gradle

+ 9
- 5
android/build.gradle 查看文件

1
 apply plugin: 'com.android.library'
1
 apply plugin: 'com.android.library'
2
 
2
 
3
+def safeExtGet(prop, fallback) {
4
+    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
5
+}
6
+
3
 repositories {
7
 repositories {
4
     mavenCentral()
8
     mavenCentral()
5
 }
9
 }
14
 }
18
 }
15
 
19
 
16
 android {
20
 android {
17
-    compileSdkVersion 23
18
-    buildToolsVersion "23.0.1"
21
+    compileSdkVersion safeExtGet('compileSdkVersion', 26)
22
+    buildToolsVersion safeExtGet('buildToolsVersion', '26.0.3')
19
     defaultConfig {
23
     defaultConfig {
20
-        minSdkVersion 16
21
-        targetSdkVersion 23
24
+        minSdkVersion safeExtGet('minSdkVersion', 16)
25
+        targetSdkVersion safeExtGet('targetSdkVersion', 26)
22
         versionCode 1
26
         versionCode 1
23
         versionName "1.0"
27
         versionName "1.0"
24
     }
28
     }
33
 }
37
 }
34
 
38
 
35
 dependencies {
39
 dependencies {
36
-    compile 'com.facebook.react:react-native:+'
40
+    compile 'com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}'
37
     //compile 'com.squareup.okhttp3:okhttp:+'
41
     //compile 'com.squareup.okhttp3:okhttp:+'
38
     //{RNFetchBlob_PRE_0.28_DEPDENDENCY}
42
     //{RNFetchBlob_PRE_0.28_DEPDENDENCY}
39
 }
43
 }