From d3b2f27e22f86902a66313f5983f13fd4cebc8ed Mon Sep 17 00:00:00 2001 From: SaeedZhiany Date: Mon, 21 Oct 2019 09:11:01 +0330 Subject: [PATCH] Load Android Gradle Plugin conditionally --- android/build.gradle | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index da298008..89bcf416 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,14 +2,20 @@ buildscript { ext.safeExtGet = {prop, fallback -> rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback } - repositories { - google() - jcenter() - } - - dependencies { - //noinspection GradleDependency - classpath("com.android.tools.build:gradle:${safeExtGet('gradlePluginVersion', '3.4.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 { + //noinspection GradleDependency + classpath("com.android.tools.build:gradle:3.5.1") + } } }