From cc4ac0a706103b58d66a6615cf83852ffd2dd498 Mon Sep 17 00:00:00 2001 From: Jack Chen Date: Tue, 29 Jan 2019 17:43:36 -0500 Subject: [PATCH] Added method to customise dependency versions (by defining rootProject.ext), same implementation consistent with other react-native libraries like react-native-fast-image & react-native-maps Upgraded android buildtools to v27.0.3 Fixed compiler warnings compile vs implementation more info Upgraded to gradle plugin v3.1.4 Upgraded to gradle v4.4 Updated Example app to reflect these changes (Inplemented fix from patrickkempff) --- android/build.gradle | 17 +++++++++++------ example/android/app/build.gradle | 16 ++++++++-------- example/android/build.gradle | 11 ++++++++++- .../gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 3653948..ea26d9b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,22 +2,27 @@ buildscript { repositories { jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.android.tools.build:gradle:3.1.4' } } apply plugin: 'com.android.library' +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} + android { - compileSdkVersion 23 - buildToolsVersion "23.0.1" + compileSdkVersion safeExtGet("compileSdkVersion", 26) + buildToolsVersion safeExtGet("buildToolsVersion", "27.0.3") defaultConfig { - minSdkVersion 16 - targetSdkVersion 22 + minSdkVersion safeExtGet("minSdkVersion", 16) + targetSdkVersion safeExtGet("targetSdkVersion", 26) versionCode 1 versionName "1.0" } @@ -31,6 +36,6 @@ repositories { } dependencies { - compile 'com.facebook.react:react-native:+' + implementation "com.facebook.react:react-native:${safeExtGet("reactNative", "+")}" // from node_modules } \ No newline at end of file diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 22f26c0..a1c45d3 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -94,13 +94,13 @@ def enableSeparateBuildPerCPUArchitecture = false def enableProguardInReleaseBuilds = false android { - compileSdkVersion 23 - buildToolsVersion "23.0.1" + compileSdkVersion rootProject.ext.compileSdkVersion + buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { applicationId "com.example" - minSdkVersion 16 - targetSdkVersion 22 + minSdkVersion rootProject.ext.minSdkVersion + targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "1.0" ndk { @@ -137,10 +137,10 @@ android { } dependencies { - compile project(':react-native-gallery-manager') - compile fileTree(dir: "libs", include: ["*.jar"]) - compile "com.android.support:appcompat-v7:23.0.1" - compile "com.facebook.react:react-native:+" // From node_modules + implementation project(':react-native-gallery-manager') + implementation fileTree(dir: "libs", include: ["*.jar"]) + implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" + implementation "com.facebook.react:react-native:+" // From node_modules } // Run this once to be able to run the application with BUCK diff --git a/example/android/build.gradle b/example/android/build.gradle index eed9972..720d3d5 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,11 +1,19 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { + ext { + buildToolsVersion = "27.0.3" + minSdkVersion = 16 + compileSdkVersion = 27 + targetSdkVersion = 26 + supportLibVersion = "27.1.1" + } + repositories { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.android.tools.build:gradle:3.1.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -20,5 +28,6 @@ allprojects { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } + google() } } diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index dbdc05d..b6517bb 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip