microsoft / react-native-code-push

React Native module for CodePush
http://appcenter.ms
Other
8.99k stars 1.47k forks source link

A JS bundle file named "null" could not be found within the downloaded contents #541

Closed igorclark closed 8 years ago

igorclark commented 8 years ago

Hi! code-push works great on our React Native app under iOS, even when pushed through into TestFlight and running a full release build. Running the identical React Native code on Android runs into this problem, where it can't seem to find the name of the bundle it's trying to replace.

10-03 15:42:07.795 2945-3354/com.arnativeapp I/ReactNativeJS: AppReducer changing codePushStatus to App/CODEPUSH_STATUS_DOWNLOADING_PACKAGE
10-03 15:42:09.939 2945-3350/com.arnativeapp W/System.err: com.microsoft.codepush.react.CodePushInvalidUpdateException: Update is invalid - A JS bundle file named "null" could not be found within the downloaded contents. Please check that you are releasing your CodePush updates using the exact same JS bundle file name that was shipped with your app's binary.
10-03 15:42:09.942 2945-3350/com.arnativeapp W/System.err:     at com.microsoft.codepush.react.CodePushUpdateManager.downloadPackage(CodePushUpdateManager.java:239)
10-03 15:42:09.942 2945-3350/com.arnativeapp W/System.err:     at com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground(CodePushNativeModule.java:201)
10-03 15:42:09.942 2945-3350/com.arnativeapp W/System.err:     at com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground(CodePushNativeModule.java:195)
10-03 15:42:09.942 2945-3350/com.arnativeapp W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:295)
10-03 15:42:09.942 2945-3350/com.arnativeapp W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
10-03 15:42:09.942 2945-3350/com.arnativeapp W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
10-03 15:42:09.942 2945-3350/com.arnativeapp W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
10-03 15:42:09.942 2945-3350/com.arnativeapp W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
10-03 15:42:09.942 2945-3350/com.arnativeapp W/System.err:     at java.lang.Thread.run(Thread.java:818)
10-03 15:42:09.974 2945-3354/com.arnativeapp I/ReactNativeJS: AppReducer changing codePushStatus to App/CODEPUSH_STATUS_UNKNOWN_ERROR
10-03 15:42:10.074 2945-3354/com.arnativeapp I/ReactNativeJS: [CodePush] Update is invalid - A JS bundle file named "null" could not be found within the downloaded contents. Please check that you are releasing your CodePush updates using the exact same JS bundle file name that was shipped with your app's binary.

Here's how we're running the Android release build:

$ react-native run-android --variant=release
[...]
:app:bundleReleaseJsAndAssets
[3:54:47 PM] <START> Building Dependency Graph
[3:54:47 PM] <START> Crawling File System
[3:54:47 PM] <START> find dependencies
[3:54:53 PM] <END>   Crawling File System (5549ms)
[3:54:53 PM] <START> Building in-memory fs for JavaScript
[3:54:53 PM] <END>   Building in-memory fs for JavaScript (326ms)
[3:54:53 PM] <START> Building in-memory fs for Assets
[3:54:53 PM] <END>   Building in-memory fs for Assets (226ms)
[3:54:53 PM] <START> Building Haste Map
[3:54:54 PM] <START> Building (deprecated) Asset Map
[3:54:54 PM] <END>   Building (deprecated) Asset Map (146ms)
[3:54:54 PM] <END>   Building Haste Map (394ms)
[3:54:54 PM] <END>   Building Dependency Graph (6517ms)
[3:55:10 PM] <END>   find dependencies (22226ms)
bundle: start
bundle: finish
bundle: Writing bundle output to: /Users/igor/Documents/Projects/<OurApp>/app/android/app/build/intermediates/assets/release/index.android.bundle
bundle: Copying 93 asset files
bundle: Done writing bundle output
bundle: Done copying assets
:app:generateBundledResourcesHashRelease
18a698db16dda1fda86b2bcf4ef324bb0e722ad2e82372ae0b15b82e6dfd6597
[...]

And this is how we're building and deploying the code-push Android deployment:

$ code-push release-react <OurApp> android --deploymentName prod-android --development false --mandatory true --bundleName index.android.bundle                                                                    [972/1553]
Detecting android app version:

Using the target binary version value "1.0" from "android/app/build.gradle".

Running "react-native bundle" command:

node node_modules/react-native/local-cli/cli.js bundle --assets-dest /var/folders/tx/ckdp0nf12ps6c9txsg6_5hq40000gn/T/CodePush --bundle-output /var/folders/tx/ckdp0nf12ps6c9txsg6_5hq40000gn/T/CodePush/index.android.bundle --dev false --entry-file index.android.js --platform android
[2:31:32 PM] <START> Building Dependency Graph
[2:31:32 PM] <START> Crawling File System
[2:31:32 PM] <START> find dependencies
[2:31:37 PM] <END>   Crawling File System (5569ms)
[2:31:37 PM] <START> Building in-memory fs for JavaScript
[2:31:38 PM] <END>   Building in-memory fs for JavaScript (283ms)
[2:31:38 PM] <START> Building in-memory fs for Assets
[2:31:38 PM] <END>   Building in-memory fs for Assets (235ms)
[2:31:38 PM] <START> Building Haste Map
[2:31:38 PM] <START> Building (deprecated) Asset Map
[2:31:38 PM] <END>   Building (deprecated) Asset Map (154ms)
[2:31:38 PM] <END>   Building Haste Map (412ms)
[2:31:38 PM] <END>   Building Dependency Graph (6510ms)
[2:31:39 PM] <END>   find dependencies (7162ms)
bundle: start
bundle: finish
bundle: Writing bundle output to: /var/folders/tx/ckdp0nf12ps6c9txsg6_5hq40000gn/T/CodePush/index.android.bundle
bundle: Done writing bundle output
bundle: Copying 93 asset files
bundle: Done copying assets

Releasing update contents to CodePush:

Upload progress:[==================================================] 100% 0.0s
 Successfully released an update containing the "/var/folders/tx/ckdp0nf12ps6c9txsg6_5hq40000gn/T/CodePush" directory to the "prod-android" deployment of the "<OurApp>" app.

The same error happens whether on debug or release builds, on the simulator or on-device, and regardless of whether we specify --bundleName index.android.bundle in the Code Push deploy command.

Are we missing something? How should we specify bundle names/locations, if so? If not, is this a bug?

Thanks for your help! 😊

igorclark commented 8 years ago

OK, after much digging, it turns out it was an error in our code. (Natch.) Sorry to have troubled you.

richardhuaaa commented 8 years ago

No worries, thanks so much for the update @igorclark and feel free to come back if you have any other issues!

sriraman commented 7 years ago

@igorclark Can you tell what was the problem with your code. I'm exactly struck in the same problem.

igorclark commented 7 years ago

Hello @sriraman, I'm afraid I can't remember exactly, but I think I was doing something pretty dumb. I do seem to remember that it wasn't really related to CodePush, it was more an error somewhere else in my code that was meaning the paths weren't right, or something like that. Sorry not to be able to shed more light.

somoso commented 3 years ago

For anyone else who has stumbled across this error and are trying to figure out the issue, the MainApplication.java isn't set up correctly and needs to be set up as directed in the README.

More specifically, I was messing around with getJSMainModuleName() not realising that ReactNativeHost has a method called. getJSBundleFile() that I'd have to override myself. What I ended up doing was copying the following:

@Override
protected String getJSBundleFile() {
        return CodePush.getJSBundleFile();
 }

right in the ReactNativeHost block of code, so my code ended up looking like:

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      List<ReactPackage> packages = new PackageList(this).getPackages();
      // bunch of old packages which original repo was never updated. CodePush wasn't here as I was on RN 0.61
      return packages;
    }

    @Nullable
    @Override
    protected String getJSBundleFile() {
      return CodePush.getJSBundleFile();
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };
atifaziz1 commented 2 years ago

Hi @igorclark !

I need your urgent help. I am getting error that:

com.microsoft.codepush.react.CodePushInvalidUpdateException: Update is invalid - A JS bundle file named "null" could not be found within the downloaded contents. Please check that you are releasing your CodePush updates using the exact same JS bundle file name that was shipped with your app's binary. at com.microsoft.codepush.react.CodePushUpdateManager.downloadPackage(CodePushUpdateManager.java:255) at com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground(CodePushNativeModule.java:290) at com.microsoft.codepush.react.CodePushNativeModule$3.doInBackground(CodePushNativeModule.java:284)

vishpatil1999 commented 1 year ago

@atifaziz1 getting same issue again on react native version 0.68.1, Please give me solution . also created new project getting same error on fresh project too. Please help me if you found solution

Saalim95 commented 1 year ago

In my case, I was making the edits in MainApplicationReactNativeHost.java file (As per doc for RN 0.68 - 0.70). Instead of this this file, use MainApplication.java.