Skip to content

Commit 1048304

Browse files
authored
loaded Android Gradle Plugin Conditionally (#18)
This wraps the Android Gradle plugin dependency in the buildscripts section of android/build.gradle in a conditional: ``` if (project == rootProject) { // ... (dependency here) } ``` The Android Gradle plugin is only required when opening the project stand-alone, not when it is included as a dependency. By doing this, the project opens correctly in Android Studio, and it can also be consumed as a native module dependency from an application project without affecting the app project (avoiding unnecessary downloads/conflicts/etc). for more info, you can refer to [this thread](facebook/react-native#25569) and especially [this comment.](facebook/react-native#25569 (comment))
2 parents 8a11105 + dfb3ca4 commit 1048304

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

android/build.gradle

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
buildscript {
2-
repositories {
2+
// The Android Gradle plugin is only required when opening the Android folder stand-alone.
3+
// This avoids unnecessary downloads and potential conflicts when the library is included as a
4+
// module dependency in an application project.
5+
if (project == rootProject) {
6+
repositories {
37
google()
48
mavenCentral()
5-
}
9+
}
610

7-
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.5.3'
11+
dependencies {
12+
classpath 'com.android.tools.build:gradle:3.5.3'
13+
}
914
}
1015
}
1116

0 commit comments

Comments
 (0)