Skip to content

Commit 0ad8a53

Browse files
authored
Merge pull request #354 from SaeedZhiany/patch-1
Load Android Gradle Plugin conditionally
2 parents 781b31c + 2d4c8cf commit 0ad8a53

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

android/build.gradle

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,30 @@ def safeExtGet(prop, fallback) {
33
}
44

55
buildscript {
6-
repositories {
7-
google()
8-
jcenter()
9-
}
10-
11-
dependencies {
12-
classpath 'com.android.tools.build:gradle:3.5.2'
6+
// The Android Gradle plugin is only required when opening the android folder stand-alone.
7+
// This avoids unnecessary downloads and potential conflicts when the library is included as a
8+
// module dependency in an application project.
9+
if (project == rootProject) {
10+
repositories {
11+
google()
12+
jcenter()
13+
}
14+
15+
dependencies {
16+
classpath("com.android.tools.build:gradle:3.5.3")
17+
}
1318
}
1419
}
1520

1621
apply plugin: 'com.android.library'
1722

1823
android {
19-
compileSdkVersion safeExtGet('compileSdkVersion', 25)
20-
buildToolsVersion safeExtGet('buildToolsVersion', '25.0.3')
24+
compileSdkVersion safeExtGet('compileSdkVersion', 28)
25+
buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
2126

2227
defaultConfig {
2328
minSdkVersion safeExtGet('minSdkVersion', 16)
24-
targetSdkVersion safeExtGet('targetSdkVersion', 22)
29+
targetSdkVersion safeExtGet('targetSdkVersion', 28)
2530
versionCode 1
2631
versionName "1.0"
2732

@@ -34,7 +39,8 @@ android {
3439
}
3540

3641
repositories {
37-
mavenCentral()
42+
google()
43+
jcenter()
3844
}
3945

4046
dependencies {

0 commit comments

Comments
 (0)