Browse Source

Update installation-android.md

Guy Carmeli 6 years ago
parent
commit
733aa56ebc
No account linked to committer's email address
1 changed files with 74 additions and 20 deletions
  1. 74
    20
      docs/docs/installation-android.md

+ 74
- 20
docs/docs/installation-android.md View File

1
 # Android Installation
1
 # Android Installation
2
 
2
 
3
+!> Make sure your Android Studio installation is updated. We recommend editing `gralde` and `java` files in Android Studio as the ide will suggest fixes and point out errors, this way you avoid most common pitfalls.
4
+
5
+
3
 1. Install `react-native-navigation` latest stable version.
6
 1. Install `react-native-navigation` latest stable version.
4
 
7
 
5
 	```sh
8
 	```sh
12
 	include ':react-native-navigation'
15
 	include ':react-native-navigation'
13
 	project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')
16
 	project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')
14
 	```
17
 	```
15
-
16
-3. Update project dependencies in `android/app/build.gradle`.
17
-	```groovy
18
-	android {
19
-		compileSdkVersion 25
20
-		buildToolsVersion "25.0.1"
21
-		...
22
-	}
23
-
24
-	dependencies {
25
-		compile fileTree(dir: "libs", include: ["*.jar"])
26
-		compile "com.android.support:appcompat-v7:23.0.1"
27
-		compile "com.facebook.react:react-native:+"
28
-		compile project(':react-native-navigation')
29
-	}
30
-	```
31
-
32
-4. In `MainActivity.java` it should extend `com.reactnativenavigation.NavigationActivity` instead of `ReactActivity`.
18
+	
19
+3. Update `android/build.gradle`
20
+
21
+```diff
22
+buildscript {
23
+    repositories {
24
++        mavenLocal()
25
++        mavenCentral()
26
++        google()
27
++        jcenter()
28
+    }
29
+    dependencies {
30
++        classpath 'com.android.tools.build:gradle:3.0.1'
31
+-        classpath 'com.android.tools.build:gradle:2.2.3'
32
+    }
33
+}
34
+
35
+allprojects {
36
+    repositories {
37
+        mavenLocal()
38
++        mavenCentral()
39
++        google()
40
+        jcenter()
41
+        maven {
42
+            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
43
+            url "$rootDir/../../node_modules/react-native/android"
44
+        }
45
+    }
46
+}
47
+```
48
+
49
+4. Update project dependencies in `android/app/build.gradle`.
50
+```groovy
51
+android {
52
+    compileSdkVersion 25
53
+    buildToolsVersion "27.0.3"
54
+
55
+    compileOptions {
56
+        sourceCompatibility JavaVersion.VERSION_1_8
57
+        targetCompatibility JavaVersion.VERSION_1_8
58
+    }
59
+    ...
60
+}
61
+
62
+dependencies {
63
+    implementation fileTree(dir: "libs", include: ["*.jar"])
64
+    implementation "com.android.support:appcompat-v7:25.4.0"
65
+    implementation "com.facebook.react:react-native:+"
66
+    implementation project(':react-native-navigation')
67
+}
68
+```
69
+	
70
+5. Make sure you're using the new gradle plugin, edit `android/gradle/wrapper/gradle-wrapper.properties`
71
+```diff
72
+distributionBase=GRADLE_USER_HOME
73
+distributionPath=wrapper/dists
74
+zipStoreBase=GRADLE_USER_HOME
75
+zipStorePath=wrapper/dists
76
++distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
77
+-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
78
+```
79
+
80
+6. Update `gradle.properties` and disable incremental resource processing
81
+```diff
82
++# Disable incremental resource processing as it broke relase build
83
++android.enableAapt2=false
84
+```
85
+
86
+7. In `MainActivity.java` it should extend `com.reactnativenavigation.NavigationActivity` instead of `ReactActivity`.
33
 
87
 
34
 	This file can be located in `android/app/src/main/java/com/yourproject/`.
88
 	This file can be located in `android/app/src/main/java/com/yourproject/`.
35
 
89
 
43
 
97
 
44
 	If you have any **react-native** related methods, you can safely delete them.
98
 	If you have any **react-native** related methods, you can safely delete them.
45
 
99
 
46
-5. In `MainApplication.java`, add the following
100
+8. In `MainApplication.java`, add the following
47
 	```java
101
 	```java
48
 	import com.reactnativenavigation.NavigationApplication;
102
 	import com.reactnativenavigation.NavigationApplication;
49
 
103
 
65
 
119
 
66
 	Make sure that `isDebug` methods is implemented.
120
 	Make sure that `isDebug` methods is implemented.
67
 
121
 
68
-6. Update `AndroidManifest.xml` and set **android:name** value to `.MainApplication`
122
+9. Update `AndroidManifest.xml` and set **android:name** value to `.MainApplication`
69
 	```xml
123
 	```xml
70
 	<application
124
 	<application
71
 		android:name=".MainApplication"
125
 		android:name=".MainApplication"