From 8b08e1ea1b2921e4828dcf77e0e462243b55931a Mon Sep 17 00:00:00 2001 From: Andrei Alecu Date: Tue, 4 Aug 2020 23:11:39 +0300 Subject: [PATCH] Update build.gradle Fixes #61 Used https://github.com/react-native-community/async-storage/blob/master/android/build.gradle for inspiration. This is a quick fix and I'm not familiar with this project so please double check that everything is ok. I have verified that this fixes #20 in our project and the workaround that was posted there is no longer necessary. Compilation seems to complete properly. --- android/build.gradle | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index a28f0dd..625d3a5 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,23 +1,31 @@ +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} buildscript { - repositories { - jcenter() - } - - dependencies { - classpath 'com.android.tools.build:gradle:1.3.1' + // The Android Gradle plugin is only required when opening the android folder stand-alone. + // This avoids unnecessary downloads and potential conflicts when the library is included as a + // module dependency in an application project. + if (project == rootProject) { + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.5.0' + } } } apply plugin: 'com.android.library' android { - compileSdkVersion 23 - buildToolsVersion "23.0.1" + compileSdkVersion safeExtGet('compileSdkVersion', 28) + buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3') defaultConfig { - minSdkVersion 16 - targetSdkVersion 22 + minSdkVersion safeExtGet('minSdkVersion', 19) + targetSdkVersion safeExtGet('targetSdkVersion', 28) versionCode 1 versionName "1.0" } @@ -27,10 +35,14 @@ android { } repositories { - mavenCentral() + mavenLocal() + maven { + // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm + url "$rootDir/../node_modules/react-native/android" + } } dependencies { - compile 'com.facebook.react:react-native:+' + implementation 'com.facebook.react:react-native:+' // From node_modules } - \ No newline at end of file +