From 3b0fcc4c0ba54c3681604902089d125d7ce319f0 Mon Sep 17 00:00:00 2001 From: Frieder Bluemle Date: Tue, 17 Sep 2019 19:24:47 -0700 Subject: [PATCH] Update build.gradle setup This also updates Android Gradle plugin to 3.5.0. --- .gitignore | 19 +++++++------- android/build.gradle | 53 ++++++++++++++++++++++----------------- android/gradle.properties | 4 --- 3 files changed, 40 insertions(+), 36 deletions(-) delete mode 100644 android/gradle.properties diff --git a/.gitignore b/.gitignore index 95367758..df98fdb0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,13 +3,6 @@ # .DS_Store -# node.js -# -node_modules/ -npm-debug.log -yarn-error.log - - # Xcode # build/ @@ -29,7 +22,6 @@ DerivedData *.ipa *.xcuserstate project.xcworkspace - # Android/IntelliJ # @@ -38,6 +30,15 @@ build/ .gradle local.properties *.iml +android/gradle/ +android/gradlew +android/gradlew.bat + +# node.js +# +node_modules/ +npm-debug.log +yarn-error.log # BUCK buck-out/ @@ -45,4 +46,4 @@ buck-out/ *.keystore # Editor config -.vscode \ No newline at end of file +.vscode diff --git a/android/build.gradle b/android/build.gradle index fcabf848..4dc43dc8 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,23 +1,22 @@ +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} buildscript { - repositories { - google() - jcenter() - } - - dependencies { - classpath 'com.android.tools.build:gradle:3.4.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' + } } } -def getExtOrDefault(name) { - return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['RNAsyncStorage_' + name] -} - -def getExtOrIntegerDefault(name) { - return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['RNAsyncStorage_' + name]).toInteger() -} - // AsyncStorage has default size of 6MB. // This is a sane limit to protect the user from the app storing too much data in the database. // This also protects the database from filling up the disk cache and becoming malformed. @@ -37,22 +36,30 @@ def useDedicatedExecutor = rootProject.hasProperty('AsyncStorage_dedicatedExecut apply plugin: 'com.android.library' android { - compileSdkVersion getExtOrIntegerDefault('compileSdkVersion') - buildToolsVersion getExtOrDefault('buildToolsVersion') - + compileSdkVersion safeExtGet('compileSdkVersion', 28) + buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3') defaultConfig { - minSdkVersion getExtOrIntegerDefault('minSdkVersion') - targetSdkVersion getExtOrIntegerDefault('targetSdkVersion') - + minSdkVersion safeExtGet('minSdkVersion', 19) + targetSdkVersion safeExtGet('targetSdkVersion', 28) buildConfigField "Long", "AsyncStorage_db_size", "${dbSizeInMB}L" buildConfigField("boolean", "AsyncStorage_useDedicatedExecutor", "${useDedicatedExecutor}") } + lintOptions { + abortOnError false + } } 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" + } + google() + jcenter() } dependencies { - implementation 'com.facebook.react:react-native:+' + //noinspection GradleDynamicVersion + implementation 'com.facebook.react:react-native:+' // From node_modules } diff --git a/android/gradle.properties b/android/gradle.properties deleted file mode 100644 index 109465ba..00000000 --- a/android/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -RNAsyncStorage_compileSdkVersion=28 -RNAsyncStorage_buildToolsVersion=28.0.3 -RNAsyncStorage_targetSdkVersion=28 -RNAsyncStorage_minSdkVersion=19 \ No newline at end of file