You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 20, 2025. It is now read-only.
@@ -199,77 +198,49 @@ To let the CodePush runtime know which deployment it should query for updates ag
199
198
200
199
## Android Setup
201
200
202
-
In order to integrate CodePush into your Android project, perform the following steps:
201
+
In order to accomodate as many developer preferences as possible, the CodePush plugin supports Android setup via two mechanisms:
203
202
204
-
### Plugin Installation (Android)
203
+
1. [**RNPM**](#plugin-installation-and-configuration-android---rnpm) - [React Native Package Manager (RNPM)](https://github.com/rnpm/rnpm) is an awesome tool that provides the simplest installation experience possible for React Native plugins. If you're already using it, or you want to use it, then we recommend this approach.
205
204
206
-
1. In your `android/settings.gradle` file, make the following additions:
207
-
208
-
```gradle
209
-
include ':app', ':react-native-code-push'
210
-
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
211
-
```
212
-
2. In your `android/app/build.gradle` file, add the `:react-native-code-push` project as a compile-time dependency:
213
-
214
-
```gradle
215
-
...
216
-
dependencies {
217
-
...
218
-
compile project(':react-native-code-push')
219
-
}
220
-
```
221
-
3. (Only needed in v1.8.0+ of the plugin) In your `android/app/build.gradle` file, add the `codepush.gradle` file as an additional build task definition underneath `react.gradle`:
2. [**"Manual"**](#plugin-installation-android---manual) - If you don't want to depend on any additional tools or are fine with a few extra installation steps (it's a one-time thing), then go with this approach.
231
206
232
-
*NOTE:These instructions are specific to apps that are usingReactNative v0.15.0-v0.17.0. If you are using v0.18.0+, then skip ahead to the next section.*
207
+
#### Plugin Installation and Configuration (Android - RNPM)
233
208
234
-
After installing the plugin and syncing your AndroidStudio project with Gradle, you need to configure your app to consult CodePushfor the location of your JS bundle, since it will "take control" of managing the current and all future versions. Todo this, perform the following steps:
209
+
1. Run`rnpm link react-native-code-push`
235
210
236
-
1. Update the `MainActivity.java` file to use CodePush via the following changes:
211
+
*Note:If you don't already have RNPM installed, you can do so by simply running `npm i -g rnpm` and then executing the above command.*
237
212
213
+
2. For Android, RNPM will also attempt to edit your MainActivity.java file to automate adding the CodePush `ReactPackage` to the runtime. However, there are a few tweaks you need to make, as follows:
214
+
238
215
```java
239
216
...
240
-
// 1. Import the plugin class
241
-
import com.microsoft.codepush.react.CodePush;
242
-
243
-
// 2. Optional: extend FragmentActivity if you intend to show a dialog prompting users about updates.
244
-
// If you do this, make sure to also add "import android.support.v4.app.FragmentActivity" below #1.
245
-
public class MainActivity extends FragmentActivity implements DefaultHardwareBackBtnHandler {
246
-
...
247
-
217
+
218
+
public class MainActivity extends ReactActivity {
219
+
// 1. Override the getJSBundleFile method in order to let
220
+
// the CodePush runtime determine where to get the JS
2. Ensure that the `android.defaultConfig.versionName` property in your `android/app/build.gradle` file is set to a semver-compliant value. Note that if the value provided is missing a patch version, the CodePush server will assume it is `0`, i.e. `1.0` will be treated as `1.0.0`.
243
+
3. Ensure that the `android.defaultConfig.versionName` property in your `android/app/build.gradle` file is set to a semver-compliant value. Note that if the value provided is missing a patch version, the CodePush server will assume it is `0`, i.e. `1.0` will be treated as `1.0.0`.
273
244
274
245
```gradle
275
246
android {
@@ -282,10 +253,34 @@ After installing the plugin and syncing your Android Studio project with Gradle,
282
253
...
283
254
}
284
255
```
256
+
257
+
#### Plugin Installation (Android - Manual)
258
+
259
+
1. In your `android/settings.gradle` file, make the following additions:
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
264
+
```
265
+
2. In your `android/app/build.gradle` file, add the `:react-native-code-push` project as a compile-time dependency:
266
+
267
+
```gradle
268
+
...
269
+
dependencies {
270
+
...
271
+
compile project(':react-native-code-push')
272
+
}
273
+
```
274
+
3. (Only needed in v1.8.0+ of the plugin) In your `android/app/build.gradle` file, add the `codepush.gradle` file as an additional build task definition underneath `react.gradle`:
*NOTE:These instructions are specific to apps that are usingReactNative v0.18.0+. If you are using v0.15.0-v0.17.0, then refer to the previous section.*
283
+
### Plugin Configuration (Android - Manual)
289
284
290
285
After installing the plugin and syncing your AndroidStudio project with Gradle, you need to configure your app to consult CodePushfor the location of your JS bundle, since it will "take control" of managing the current and all future versions. Todo this, perform the following steps:
291
286
@@ -302,7 +297,7 @@ After installing the plugin and syncing your Android Studio project with Gradle,
0 commit comments