Skip to content

Commit

Permalink
Load Android Gradle Plugin conditionally (#459)
Browse files Browse the repository at this point in the history
This wraps the Android Gradle plugin dependency in the buildscripts section of android/build.gradle in a conditional.
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)).
  • Loading branch information
SaeedZhiany authored Jul 6, 2020
1 parent a6c50a9 commit 6ecf71b
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@

buildscript {
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.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.6.2")
}
}
}

Expand Down

0 comments on commit 6ecf71b

Please sign in to comment.