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.

Staging release of app crashes immediately after opening #462

@greena13

Description

@greena13

Solution: See comments below.

Update: After resetting the emulator completely and building again I no longer get the error about being unable to locate the bundle hash. The logs just say Loading JS bundle from "assets://index.android.bundle" and then the app crashes.

Update 2: This seems to function correctly when building a production build, but not a staging one. They should be effectively the same, so I am not sure what is different at this stage.

I have followed the installation instructions on the Readme and my MainActivity.java looks like this:

package com.mypackage;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.microsoft.codepush.react.CodePush;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;


import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {
  private CodePush _codePush;

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {

    @Override
    protected boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected String getJSBundleFile() {
      return _codePush.getJSBundleFile("index.android.bundle");
    }

    @Override
    protected List<ReactPackage> getPackages() {
      _codePush = new CodePush(BuildConfig.CODEPUSH_KEY, MainApplication.this, BuildConfig.DEBUG);

      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          _codePush
      );
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
      return mReactNativeHost;
  }
}

I have added the codepush.gradle to app/build.gradle

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"

After creating a staging bundle

 code-push release-react <appName> Staging

I built a staging APK

cd android && ./gradlew assembleStaging

Which successfully builds a staging build variant (deployment key omitted)

 staging {
        ...
        applicationIdSuffix ".staging"         
        buildConfigField "String", "CODEPUSH_KEY", '"<KEY>"'
    }

I then installed it on an Android emulator

./gradlew installStaging

But when I open up the app on the emulator, it immediately crashes. So I viewed the debug log using

 code-push debug android

And opened (not resumed) the app again and I see the following output

Loading JS bundle from "assets://index.android.bundle"
Unable to get the hash of the binary's bundled resources - "codepush.gradle" may have not been added to the build definition.

I checked the release history using

 code-push deployment ls

And it shows No installs recorded for the Staging deployment.

I am using:

code push CLI 1.12.3-beta
code push 1.8.0-beta
react-native-code-push 1.14.1-beta
react-native 0.29.2

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