Browse Source

fix: Android stand-alone build.gradle with .gitignore (#33)

Rapsssito 4 years ago
parent
commit
c1c143bcad
2 changed files with 26 additions and 0 deletions
  1. 2
    0
      .gitignore
  2. 24
    0
      android/build.gradle

+ 2
- 0
.gitignore View File

@@ -38,6 +38,8 @@ build/
38 38
 .gradle
39 39
 local.properties
40 40
 *.iml
41
+android/gradle
42
+android/gradlew*
41 43
 
42 44
 # BUCK
43 45
 buck-out/

+ 24
- 0
android/build.gradle View File

@@ -2,6 +2,21 @@ def getExtOrDefault(name, defaultVaue) {
2 2
   return rootProject.ext.has(name) ? rootProject.ext.get(name) : defaultVaue
3 3
 }
4 4
 
5
+buildscript {
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
+        dependencies {
15
+            classpath 'com.android.tools.build:gradle:3.5.0'
16
+        }
17
+    }
18
+}
19
+
5 20
 apply plugin: 'com.android.library'
6 21
 
7 22
 android {
@@ -16,6 +31,15 @@ android {
16 31
   }
17 32
 }
18 33
 
34
+repositories {
35
+    google()
36
+    maven {
37
+        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
38
+        url "$rootDir/../node_modules/react-native/android"
39
+    }
40
+    jcenter()
41
+}
42
+
19 43
 dependencies {
20 44
   //noinspection GradleDynamicVersion
21 45
   implementation 'com.facebook.react:react-native:+'