Android Setup Guide
This page covers the Android-specific parts of a bare React Native SrcPush integration.
For the full flow, start with React Native SDK Setup.
Files to update
android/app/build.gradleandroid/app/src/main/res/values/strings.xmlandroid/app/src/main/java/.../MainApplication.(kt|java)
Only touch AndroidManifest.xml if your project or library needs extra metadata flags.
1. Add the Gradle helper
In android/app/build.gradle, add the SrcPush helper near your other apply from: lines:
apply from: "../../node_modules/@srcpush/react-native-code-push/android/codepush.gradle"
2. Choose a single source of truth for the deployment key
You can define CodePushDeploymentKey in build.gradle or strings.xml. Avoid duplicating it in both places unless the app already depends on that pattern.
Example using build type placeholders:
buildTypes {
debug {
resValue "string", "CodePushDeploymentKey", '"YOUR_ANDROID_STAGING_KEY"'
}
release {
resValue "string", "CodePushDeploymentKey", '"YOUR_ANDROID_PRODUCTION_KEY"'
}
}
Example using strings.xml:
<resources>
<string name="CodePushDeploymentKey">YOUR_ANDROID_DEPLOYMENT_KEY</string>
<string name="CodePushServerUrl">https://api.srcpush.com</string>
<string name="CodePushPublicKey">YOUR_PUBLIC_KEY</string>
</resources>
CodePushServerUrl and CodePushPublicKey are optional unless your environment requires them.
3. Override getJSBundleFile()
Import CodePush in MainApplication and return the bundle path from the React Native host:
import com.microsoft.codepush.react.CodePush
override fun getJSBundleFile(): String {
return CodePush.getJSBundleFile()
}
React Native host classes vary between versions. Keep the current DefaultReactNativeHost or legacy host shape and only add the override where it belongs.
4. Keep tracked files generic
Commit placeholders, not real values:
YOUR_ANDROID_STAGING_KEYYOUR_ANDROID_PRODUCTION_KEYYOUR_ANDROID_DEPLOYMENT_KEYYOUR_PUBLIC_KEY
If your release pipeline needs to materialize real values before publishing, inject them during CI rather than committing them.
Release note
For Android release commands, prefer explicit scripts such as:
{
"scripts": {
"srcpush:android:staging": "srcpush release-react YOUR_APP_NAME_ANDROID android -d Staging --privateKeyPath ./keys/private.pem --useHermes",
"srcpush:android:prod": "srcpush release-react YOUR_APP_NAME_ANDROID android -d Production --privateKeyPath ./keys/private.pem --useHermes"
}
}