Android Setup
Once you've installed @deploypulseio/react-native-code-push, you need to integrate it into your Android project. If you are using Expo managed workflow, see Expo Setup instead — no native file editing required.
Patch build.gradle
In android/app/build.gradle, add the CodePush gradle file at the end:
apply from: "../../node_modules/@deploypulseio/react-native-code-push/android/codepush.gradle"
Patch MainApplication.kt
React Native 0.76 – 0.81
// 1. Import the plugin class.
import com.microsoft.codepush.react.CodePush
class MainApplication : Application(), ReactApplication {
override val reactNativeHost: ReactNativeHost =
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> = PackageList(this).packages.apply {
// add(MyReactNativePackage())
}
// 2. Override getJSBundleFile so CodePush resolves the bundle path on each start.
override fun getJSBundleFile(): String {
return CodePush.getJSBundleFile()
}
}
}
React Native 0.82+
// 1. Import the plugin class.
import com.microsoft.codepush.react.CodePush
class MainApplication : Application(), ReactApplication {
override val reactHost: ReactHost by lazy {
getDefaultReactHost(
context = applicationContext,
packageList = PackageList(this).packages.apply {
// add(MyReactNativePackage())
},
// 2. RN 0.82+ uses ReactHost config instead of overriding getJSBundleFile().
jsBundleFilePath = CodePush.getJSBundleFile(),
)
}
}
Add keys to strings.xml
Open android/app/src/main/res/values/strings.xml and add:
<resources>
<string name="app_name">AppName</string>
<string moduleConfig="true" name="CodePushDeploymentKey">YOUR_ANDROID_DEPLOYMENT_KEY</string>
<string moduleConfig="true" name="CodePushServerUrl">https://api.deploypulse.io</string>
</resources>
Retrieve your deployment key with:
dpctl deployment list <AppName>
Code Signing (optional)
To verify bundle integrity before applying updates, add your public key to strings.xml:
<string name="CodePushPublicKey">-----BEGIN PUBLIC KEY-----
YOUR_PUBLIC_KEY_HERE
-----END PUBLIC KEY-----</string>
See the Code Signing guide for full setup instructions.
Next step
Return to the React Native SDK page for usage and notifyAppReady instructions.
