|
@@ -53,8 +53,23 @@
|
53
|
53
|
include ':react-native-navigation'
|
54
|
54
|
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')
|
55
|
55
|
```
|
|
56
|
+## 2. Updating Gradle build files.
|
56
|
57
|
|
57
|
|
-### 2. Update `android/build.gradle`:
|
|
58
|
+> react-native-navigation supports multiple React Native versions. Target the React Native version required by your project by specifying the RNN build flavor you require.
|
|
59
|
+><br><br>Available options:
|
|
60
|
+>
|
|
61
|
+>* `reactNative51`: Support for React Native 0.51-0.54
|
|
62
|
+>* `reactNative55`: Support for React Native 0.55
|
|
63
|
+>* `reactNative56`: Support for React Native 0.56 and above
|
|
64
|
+>
|
|
65
|
+><br>For example: To target React Native 0.56
|
|
66
|
+> <br><br>Replace the following line in step 2.2:<br>
|
|
67
|
+>`missingDimensionStrategy "RNN.reactNativeVersion", "reactNative51"`
|
|
68
|
+><br>with:<br>
|
|
69
|
+>`missingDimensionStrategy "RNN.reactNativeVersion", "reactNative56"`
|
|
70
|
+><br><br>Make a choice in step 2.3 to alter your Android run-command (**prefered**) or ignore the unused buildvariants in your root build.gradle file.
|
|
71
|
+
|
|
72
|
+### 2.1 Update `android/build.gradle`:
|
58
|
73
|
|
59
|
74
|
```diff
|
60
|
75
|
buildscript {
|
|
@@ -83,9 +98,11 @@ allprojects {
|
83
|
98
|
+ maven { url 'https://jitpack.io' }
|
84
|
99
|
}
|
85
|
100
|
}
|
|
101
|
+
|
|
102
|
+
|
86
|
103
|
```
|
87
|
104
|
|
88
|
|
-### 3. Update project dependencies in `android/app/build.gradle`.
|
|
105
|
+### 2.2 Update project dependencies in `android/app/build.gradle`.
|
89
|
106
|
|
90
|
107
|
```groovy
|
91
|
108
|
android {
|
|
@@ -95,7 +112,7 @@ android {
|
95
|
112
|
defaultConfig {
|
96
|
113
|
minSdkVersion 19
|
97
|
114
|
targetSdkVersion 25
|
98
|
|
- missingDimensionStrategy "RNN.reactNativeVersion", "reactNative51" // <- See note below for further instruction regarding compatibility with other React Native versions
|
|
115
|
+ missingDimensionStrategy "RNN.reactNativeVersion", "reactNative51" // <- See note above for further instruction regarding compatibility with other React Native versions
|
99
|
116
|
...
|
100
|
117
|
}
|
101
|
118
|
|
|
@@ -113,19 +130,38 @@ dependencies {
|
113
|
130
|
implementation project(':react-native-navigation')
|
114
|
131
|
}
|
115
|
132
|
```
|
116
|
|
-> react-native-navigation supports multiple React Native versions. Target the React Native version required by your project by specifying the RNN build flavor you require.
|
117
|
|
-><br><br>Available options:
|
118
|
|
->
|
119
|
|
->* `reactNative51`: Support for React Native 0.51-0.54
|
120
|
|
->* `reactNative55`: Support for React Native 0.55
|
121
|
|
->* `reactNative56`: Support for React Native 0.56 and above
|
122
|
|
->
|
123
|
|
-><br>For example, To target React Native 0.55, replace the following line:<br>
|
124
|
|
->`missingDimensionStrategy "RNN.reactNativeVersion", "reactNative51"`
|
125
|
|
-><br>with:<br>
|
126
|
|
->`missingDimensionStrategy "RNN.reactNativeVersion", "reactNative55"`
|
127
|
133
|
|
128
|
|
-### 4. Make sure you're using the new gradle plugin, edit `android/gradle/wrapper/gradle-wrapper.properties`
|
|
134
|
+### 2.3 Compiling the correct build flavor
|
|
135
|
+Now that you've specified the RNN flavor you need to compile acording to the installed React Native version, you need to ignore the other flavors RNN provides.
|
|
136
|
+
|
|
137
|
+1. **The preferable option**: Use the configuration specified in the `app` module. The RNN flavor you would like to build is specified in `app/build.gradle` - therefore in order to compile only that flavor, instead of building your entire project using `./gradlew assembleDebug`, you should instruct gradle to build the app module: `./gradlew app:asembleDebug`. The easiest way is to add a package.json command to build and install your debug Android APK since the RN-CLI run-android command will no longer be of use.
|
|
138
|
+```
|
|
139
|
+"scripts": {
|
|
140
|
+ "run-android": "cd ./android && ./gradlew app:assembleDebug && ./gradlew installDebug"
|
|
141
|
+}
|
|
142
|
+```
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+2. Alternatively, explicitly ignore unwanted flavors in your project's root `build.gradle`. (Note: As more build variants come available in the future, you will need to adjust this list. While this option lets you keep the CLI command ```react-native run-android``` it comes at a cost of future upkeep.)
|
|
146
|
+```diff
|
|
147
|
++subprojects { subproject ->
|
|
148
|
++ afterEvaluate {
|
|
149
|
++ if ((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
|
|
150
|
++ android {
|
|
151
|
++ variantFilter { variant ->
|
|
152
|
++ def names = variant.flavors*.name
|
|
153
|
++ if (names.contains("reactNative51") || names.contains("reactNative55")) { // <- See note above for further instruction regarding compatibility with other React Native versions
|
|
154
|
++ // Gradle ignores any variants that satisfy the conditions above.
|
|
155
|
++ setIgnore(true)
|
|
156
|
++ }
|
|
157
|
++ }
|
|
158
|
++ }
|
|
159
|
++ }
|
|
160
|
++ }
|
|
161
|
++}
|
|
162
|
+```
|
|
163
|
+
|
|
164
|
+### 3. Make sure you're using the new gradle plugin, edit `android/gradle/wrapper/gradle-wrapper.properties`
|
129
|
165
|
|
130
|
166
|
```diff
|
131
|
167
|
distributionBase=GRADLE_USER_HOME
|
|
@@ -136,14 +172,16 @@ zipStorePath=wrapper/dists
|
136
|
172
|
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
|
137
|
173
|
```
|
138
|
174
|
|
139
|
|
-### 5. Update `gradle.properties` and disable incremental resource processing
|
|
175
|
+### 4. Update `gradle.properties` and disable incremental resource processing
|
140
|
176
|
|
141
|
177
|
```diff
|
142
|
178
|
+# Disable incremental resource processing as it broke release build
|
143
|
179
|
+android.enableAapt2=false
|
144
|
180
|
```
|
145
|
181
|
|
146
|
|
-### 6. In `MainActivity.java` it should extend `com.reactnativenavigation.NavigationActivity` instead of `ReactActivity`.
|
|
182
|
+### 5. Update `MainActivity.java`
|
|
183
|
+
|
|
184
|
+`MainActivity.java` should extend `com.reactnativenavigation.NavigationActivity` instead of `ReactActivity`.
|
147
|
185
|
|
148
|
186
|
This file can be located in `android/app/src/main/java/com/yourproject/`.
|
149
|
187
|
|
|
@@ -157,7 +195,7 @@ public class MainActivity extends NavigationActivity {
|
157
|
195
|
|
158
|
196
|
If you have any **react-native** related methods, you can safely delete them.
|
159
|
197
|
|
160
|
|
-### 7. In `MainApplication.java`, add the following
|
|
198
|
+### 6. In `MainApplication.java`, add the following
|
161
|
199
|
|
162
|
200
|
```java
|
163
|
201
|
import com.reactnativenavigation.NavigationApplication;
|
|
@@ -178,7 +216,7 @@ public class MainApplication extends NavigationApplication {
|
178
|
216
|
```
|
179
|
217
|
Make sure that `isDebug` method is implemented.
|
180
|
218
|
|
181
|
|
-### 8. Update `AndroidManifest.xml` and set `application` **android:name** value to `.MainApplication`
|
|
219
|
+### 7. Update `AndroidManifest.xml` and set `application` **android:name** value to `.MainApplication`
|
182
|
220
|
|
183
|
221
|
```xml
|
184
|
222
|
<application
|
|
@@ -186,7 +224,7 @@ Make sure that `isDebug` method is implemented.
|
186
|
224
|
...
|
187
|
225
|
/>
|
188
|
226
|
```
|
189
|
|
-### 9. Force the same support library version across all dependencies
|
|
227
|
+### 8. Force the same support library version across all dependencies
|
190
|
228
|
|
191
|
229
|
Some of your dependencies might require a different version of one of Google's support library packages. This results in compilation errors similar to this:
|
192
|
230
|
|
|
@@ -220,4 +258,4 @@ dependencies {
|
220
|
258
|
implementation 'com.android.support:appcompat-v7:25.4.0'
|
221
|
259
|
}
|
222
|
260
|
|
223
|
|
-```
|
|
261
|
+```
|