|
| 1 | +def safeExtGet(prop, fallback) { |
| 2 | + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback |
| 3 | +} |
1 | 4 |
|
2 | 5 | buildscript {
|
3 | 6 | repositories {
|
4 | 7 | google()
|
5 | 8 | jcenter()
|
6 | 9 | }
|
7 |
| - |
8 |
| - dependencies { |
9 |
| - classpath 'com.android.tools.build:gradle:3.4.1' |
| 10 | + // The Android Gradle plugin is only required when opening the android folder stand-alone. |
| 11 | + // This avoids unnecessary downloads and potential conflicts when the library is included as a |
| 12 | + // module dependency in an application project. |
| 13 | + if (project == rootProject) { |
| 14 | + dependencies { |
| 15 | + classpath 'com.android.tools.build:gradle:3.4.1' |
| 16 | + } |
10 | 17 | }
|
11 | 18 | }
|
12 | 19 |
|
@@ -37,22 +44,34 @@ def useDedicatedExecutor = rootProject.hasProperty('AsyncStorage_dedicatedExecut
|
37 | 44 | apply plugin: 'com.android.library'
|
38 | 45 |
|
39 | 46 | android {
|
40 |
| - compileSdkVersion getExtOrIntegerDefault('compileSdkVersion') |
41 |
| - buildToolsVersion getExtOrDefault('buildToolsVersion') |
42 |
| - |
| 47 | + compileSdkVersion safeExtGet('compileSdkVersion', 28) |
| 48 | + buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3') |
43 | 49 | defaultConfig {
|
44 |
| - minSdkVersion getExtOrIntegerDefault('minSdkVersion') |
45 |
| - targetSdkVersion getExtOrIntegerDefault('targetSdkVersion') |
46 |
| - |
| 50 | + minSdkVersion safeExtGet('minSdkVersion', 19) |
| 51 | + targetSdkVersion safeExtGet('targetSdkVersion', 28) |
47 | 52 | buildConfigField "Long", "AsyncStorage_db_size", "${dbSizeInMB}L"
|
48 | 53 | buildConfigField("boolean", "AsyncStorage_useDedicatedExecutor", "${useDedicatedExecutor}")
|
49 | 54 | }
|
| 55 | + lintOptions { |
| 56 | + abortOnError false |
| 57 | + } |
50 | 58 | }
|
51 | 59 |
|
52 | 60 | repositories {
|
53 |
| - mavenCentral() |
| 61 | + mavenLocal() |
| 62 | + maven { |
| 63 | + // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm |
| 64 | + url "$rootDir/../node_modules/react-native/android" |
| 65 | + } |
| 66 | + maven { |
| 67 | + // Android JSC is installed from npm |
| 68 | + url "$rootDir/../node_modules/jsc-android/dist" |
| 69 | + } |
| 70 | + google() |
| 71 | + jcenter() |
54 | 72 | }
|
55 | 73 |
|
56 | 74 | dependencies {
|
57 |
| - implementation 'com.facebook.react:react-native:+' |
| 75 | + //noinspection GradleDynamicVersion |
| 76 | + implementation 'com.facebook.react:react-native:+' // From node_modules |
58 | 77 | }
|
0 commit comments