This repository was archived by the owner on May 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Copy link
Copy link
Closed
Description
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
- Follow instructions for RN > 60 https://docs.microsoft.com/en-us/appcenter/distribution/codepush/rn-get-started#android-setup
- Follow instructions for https://docs.microsoft.com/en-us/appcenter/distribution/codepush/rn-deployment#android
- Run
gradlew bundleRelease - Upload .aab file to the internal test track on Google Play Store
- 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 = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')app/build.gradle
...
project.ext.react = [
// custom for dep react-native-jitsi-meet
bundleAssetName: "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-meet
import androidx.annotation.Nullable;
// custom for CodePush
import com.microsoft.codepush.react.CodePush;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
return packages;
}
// 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
@Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile("app.bundle");
}
@Override
protected String getJSMainModuleName() {
return "index";
}
// custom for deb react-native-jitsi-meet
@Override
protected @Nullable String getBundleAssetName() {
return "app.bundle";
}
};
...
@Override
public void onCreate() {
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
gustavopch, dimatretyak, rafalzawadzki, desaawa, jarod-legault and 8 more
Metadata
Metadata
Assignees
Labels
No labels