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.
*NOTE: These instructions are specific to apps that are using React Native v0.15.0-v0.17.0. If you are using v0.18.0+, then skip ahead to the next section.*
147
150
148
151
After installing the plugin and syncing your Android Studio project with Gradle, you need to configure your app to consult CodePush for the location of your JS bundle, since it will "take control" of managing the current and all future versions. To do this, perform the following steps:
149
152
@@ -196,6 +199,61 @@ After installing the plugin and syncing your Android Studio project with Gradle,
*NOTE: These instructions are specific to apps that are using React Native v0.18.0+. If you are using v0.15.0-v0.17.0, then refer to the previous section.*
205
+
206
+
After installing the plugin and syncing your Android Studio project with Gradle, you need to configure your app to consult CodePush for the location of your JS bundle, since it will "take control" of managing the current and all future versions. To do this, perform the following steps:
207
+
208
+
1. Update the `MainActivity.java` file to use CodePush via the following changes:
209
+
210
+
```java
211
+
...
212
+
// 1. Import the plugin class
213
+
import com.microsoft.codepush.react.CodePush;
214
+
215
+
public class MainActivity extends ReactActivity {
216
+
// 2. Define a private field to hold the CodePush runtime instance
217
+
private CodePush _codePush;
218
+
219
+
...
220
+
221
+
// 3. Override the getJSBundleFile method in order to let
222
+
// the CodePush runtime determine where to get the JS
// 4. Instantiate an instance of the CodePush runtime, using the right deployment key
232
+
this._codePush = new CodePush("0dsIDongIcoH0mqAmoR0CYb5FhBZNy1w4Bf-l", this, BuildConfig.DEBUG);
233
+
234
+
// 5. Add the CodePush package to the list of existing packages
235
+
return Arrays.<ReactPackage>asList(
236
+
new MainReactPackage(), this._codePush.getReactPackage());
237
+
}
238
+
239
+
...
240
+
}
241
+
```
242
+
243
+
2. Ensure that the `android.defaultConfig.versionName` property in your `android/app/build.gradle` file is set to a semver compliant value (i.e. "1.0.0" not "1.0")
244
+
245
+
```gradle
246
+
android {
247
+
...
248
+
defaultConfig {
249
+
...
250
+
versionName "1.0.0"
251
+
...
252
+
}
253
+
...
254
+
}
255
+
```
256
+
199
257
## Plugin Usage
200
258
201
259
With the CodePush plugin downloaded and linked, and your app asking CodePush where to get the right JS bundle from, the only thing left is to add the necessary code to your app to control the following policies:
0 commit comments