Skip to content

Commit c3faee6

Browse files
authored
fix: make android gradle safe by adding safeExtGet
1 parent a065b4f commit c3faee6

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

android/build.gradle

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,58 @@
1+
buildscript {
2+
if (project == rootProject) {
3+
repositories {
4+
google()
5+
jcenter()
6+
}
7+
8+
dependencies {
9+
classpath 'com.android.tools.build:gradle:3.5.3'
10+
}
11+
}
12+
}
13+
114
apply plugin: 'com.android.library'
215

3-
android {
4-
compileSdkVersion 28
5-
buildToolsVersion "28.0.3"
16+
def safeExtGet(prop, fallback) {
17+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
18+
}
619

20+
android {
21+
compileSdkVersion safeExtGet('compileSdkVersion', 29)
22+
buildToolsVersion safeExtGet('buildToolsVersion', '29.0.2')
723
defaultConfig {
8-
minSdkVersion rootProject.hasProperty('minSdkVersion') ? rootProject.minSdkVersion : 16
9-
targetSdkVersion 28
24+
minSdkVersion safeExtGet('minSdkVersion', 16)
25+
targetSdkVersion safeExtGet('targetSdkVersion', 29)
1026
versionCode 1
1127
versionName "1.0"
12-
ndk {
13-
abiFilters "armeabi-v7a", "x86"
28+
29+
}
30+
31+
buildTypes {
32+
release {
33+
minifyEnabled false
1434
}
1535
}
1636
lintOptions {
17-
warning 'InvalidPackage'
37+
disable 'GradleCompatible'
38+
}
39+
compileOptions {
40+
sourceCompatibility JavaVersion.VERSION_1_8
41+
targetCompatibility JavaVersion.VERSION_1_8
1842
}
1943
}
2044

21-
dependencies {
22-
implementation 'com.facebook.react:react-native:+'
45+
repositories {
46+
mavenLocal()
47+
maven {
48+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
49+
url("$rootDir/../node_modules/react-native/android")
50+
}
51+
google()
52+
jcenter()
2353
}
2454

55+
dependencies {
56+
//noinspection GradleDynamicVersion
57+
implementation "com.facebook.react:react-native:+" // From node_modules
58+
}

0 commit comments

Comments
 (0)