Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
This repository was archived by the owner on May 20, 2025. It is now read-only.

Unable to get the hash of the binary's bundled resources - "codepush.gradle" may have not been added to the build definition. #1981

Description

@SeveHo

Hi my RN Application is crashing for release builds with the error: [CodePush] Unable to get the hash of the binary's bundled resources - "codepush.gradle" may have not been added to the build definition. Below you can find my description. Please help!!

Steps to Reproduce

  1. Follow instructions for RN > 60 https://docs.microsoft.com/en-us/appcenter/distribution/codepush/rn-get-started#android-setup
  2. Follow instructions for https://docs.microsoft.com/en-us/appcenter/distribution/codepush/rn-deployment#android
  3. Run gradlew bundleRelease
  4. Upload .aab file to the internal test track on Google Play Store
  5. Upload bundle to CodePush: appcenter codepush release-react -b app.bundle -a <REDACTED>/<REDACTED> -d Staging

Resulting Setup

settings.gradle

include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir =newFile(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')

app/build.gradle

...
project.ext.react = [
// custom for dep react-native-jitsi-meetbundleAssetName: "app.bundle",
enableHermes: true,
]
apply from: "../../node_modules/react-native/react.gradle"// Custom for CodePush
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"// Added by sentry cli
apply from: "../../node_modules/@sentry/react-native/sentry.gradle"...
android {
buildTypes {
debug {
...
}
release {
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"// Important Detox-specific additions to pro-guard
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"// Custom for CodePush
resValue "string", "CodePushDeploymentKey", '"<Redacted>"'
}
// The naming convention for releaseStaging is significant due to this line https://github.com/facebook/react-native/blob/e083f9a139b3f8c5552528f8f8018529ef3193b9/react.gradle#L79
releaseStaging {
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"// Important Detox-specific additions to pro-guard
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"// Custom for CodePush
resValue "string", "CodePushDeploymentKey", '"<Redacted>"'// Note: It is a good idea to provide matchingFallbacks for the new buildType you create to prevent build issues// Add the following line if not already there
matchingFallbacks = ['release']
}
}
}

MainApplication.java

...
// custom for deb react-native-jitsi-meetimportandroidx.annotation.Nullable;
// custom for CodePushimportcom.microsoft.codepush.react.CodePush;
publicclassMainApplicationextendsApplicationimplementsReactApplication {
privatefinalReactNativeHostmReactNativeHost =
newReactNativeHost(this) {
@OverridepublicbooleangetUseDeveloperSupport() {
returnBuildConfig.DEBUG;
}
@OverrideprotectedList<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = newPackageList(this).getPackages();
returnpackages;
}
// Custom for CodePush// Override the getJSBundleFile method in order to let// the CodePush runtime determine where to get the JS// bundle location from on each app start. Specify bundle name due to change for rn-jitsi-meet@OverrideprotectedStringgetJSBundleFile() {
returnCodePush.getJSBundleFile("app.bundle");
}
@OverrideprotectedStringgetJSMainModuleName() {
return"index";
}
// custom for deb react-native-jitsi-meet@Overrideprotected@NullableStringgetBundleAssetName() {
return"app.bundle";
}
};
...
@OverridepublicvoidonCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */false);
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
}
...

Expected Behavior

The app should load the bundle from CodePush and start properly like when testet with npx react-native run-android --variant release

Actual Behavior

The app crashes with the following error

[CodePush] Loading JS bundle from "assets://app.bundle"
[CodePush] Unable to get the hash of the binary's bundled resources - "codepush.gradle" may have not been added to the build definition.
AndroidRuntime: FATAL EXCEPTION: mqt_js

Environment

  • react-native-code-push version: 6.4.0
  • react-native version: 63.3
  • iOS/Android/Windows version: Android 10
  • Does this reproduce on a debug build or release build? Release build bundle with bundleRelease command
  • Does this reproduce on a simulator, or only on a physical device? Only on a physical device

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions