microsoft / react-native-code-push

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

[Android]: 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. RN version - 0.64.0 and react-native-code-push version - 7.0.1 #2083

Open aashray-systango opened 3 years ago

aashray-systango commented 3 years ago

The code push changes are not reflecting as expected on android, works fine for iOS, the integration was done properly following android setup guide : https://github.com/microsoft/react-native-code-push/blob/HEAD/docs/setup-android.md

Steps to Reproduce

  1. Create a release build, having
  2. Do some changes, to test
  3. Ran code push release command: appcenter codepush release-react -a / -d test-variant-one
  4. Code push changes released successfully
  5. had "updateDialog: true" so go the alert stating new update once clicked on install, it installed the update but the changes didn't reflected

Expected Behavior

What you expected to happen?

Actual Behavior

What actually happens?

Should reflect the changes

Got error- 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.

Complete Error:

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) at android.os.AsyncTask$3.call(AsyncTask.java:378) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run

Environment

XB-Paul commented 3 years ago

me too

hero70312 commented 3 years ago

Both android and iOS work normally at react-native 0.63.0. But android update fail while I use react-native 0.64.0. (iOS work normally at react-native 0.64.0)

mahaaoo commented 2 years ago

me too

ghost commented 2 years ago

This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs within 15 days of this comment.

ambisign-gavin commented 2 years ago

I had the same issue too. In my project, the update works fine on the debug mode, but not working on the release mode, and I found out the problem might be related to the expo, because of the expo using the ReactNativeHostWrapper class to wrapper the ReactNativeHost, and when I removed the ReactNativeHostWrapper the code push is working fine on the release mode, so I guess the ReactNativeHostWrapper might have the different logic and flow for getJSBundleFile method on the release mode.

casaumayman commented 2 years ago

Me too, any update?

Klemminn commented 2 years ago

Same here :(

Klemminn commented 2 years ago

I had the same issue too. In my project, the update works fine on the debug mode, but not working on the release mode, and I found out the problem might be related to the expo, because of the expo using the ReactNativeHostWrapper class to wrapper the ReactNativeHost, and when I removed the ReactNativeHostWrapper the code push is working fine on the release mode, so I guess the ReactNativeHostWrapper might have the different logic and flow for getJSBundleFile method on the release mode.

Is it okay to remove ReactNativeHostWrapper? What did you replace it with, and were there any drawbacks?

ambisign-gavin commented 2 years ago

Is it okay to remove ReactNativeHostWrapper? What did you replace it with, and were there any drawbacks?

The react-native-code-push is the experimental feature for my project, so I haven't replaced it yet.

Dooqp commented 1 year ago

-----FIX----- @doomkit @aashray-systango @casaumayman @Klemminn @ambisign-gavin @XB-Paul @hero70312 @mahaaoo

I've faced with the same issue and fixed it by overriding getJSBundleFile method inside MainApplicationReactNativeHost class. The problem was I was using new architecture for android but documentation only talks about overriding getJSBundleFile method inside ReactNativeHost (which is used if newarchitecture is disabled)

...
// 1. Import the plugin class.
import com.microsoft.codepush.react.CodePush;

public class MainApplication extends Application implements ReactApplication {

    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        ...

        // 2. Override the getJSBundleFile method in order to let
        // the CodePush runtime determine where to get the JS
        // bundle location from on each app start
        @Override
        protected String getJSBundleFile() {
            return CodePush.getJSBundleFile();
        }
    };
}

but if the new architecture is enabled react-native uses MainApplicationReactNativeHost which is inside "newarchitecture" folder of your project. So just override this method there as well and it will work. (It did work on my case at least).

NOTE: My project is not an Expo project so you probably should make some tweaks for expo but I assume that logic is same.

mizhipeng commented 3 months ago

thank you @Dooqp