microsoft / react-native-code-push

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

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. #2540

Closed vishpatil1999 closed 9 months ago

vishpatil1999 commented 1 year ago

Thanks so much for filing an issue or feature request! Please fill out the following (wherever relevant):

Steps to Reproduce

1.install react-native-code-push on react native version 0.68.1

Expected Behavior

working on ios perfectly but getting error for android

Actual Behavior

codepush gets downloaded and unable to replace js bundle

  STACK TRACE AND/OR SCREENSHOTS

Reproducible Demo

Environment

(The more info the faster we will be able to address it!)

pnthach95 commented 1 year ago

I have same issue on RN 0.72

pnthach95 commented 1 year ago

Turn out I forgot to re-add getJSBundleFile in upgrade from 70 to 72 process. This is not my issue anymore. You should check getJSBundleFile is in the right place.

vishpatil1999 commented 1 year ago

@pnthach95 Can you pplease share your source code

pnthach95 commented 1 year ago

android/app/src/main/java/com/newexample/MainApplication.java

import com.facebook.soloader.SoLoader;
+import com.microsoft.codepush.react.CodePush;

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost =
      new DefaultReactNativeHost(this) {

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

        @Override
        protected boolean isNewArchEnabled() {
          return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
        }
      };
vishpatil1999 commented 1 year ago

@pnthach95 Please share whole code as I already added getJSBundleFile() in MainApplication.java . Still getting same issue

pnthach95 commented 1 year ago
package com.newexample;

import android.app.Application;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.defaults.DefaultReactNativeHost;
import com.facebook.soloader.SoLoader;
import com.microsoft.codepush.react.CodePush;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

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

        @Override
        protected List<ReactPackage> getPackages() {
          @SuppressWarnings("UnnecessaryLocalVariable")
          List<ReactPackage> packages = new PackageList(this).getPackages();
          // Packages that cannot be autolinked yet can be added manually here, for example:
          // packages.add(new MyReactNativePackage());
          return packages;
        }

        @Override
        protected String getJSMainModuleName() {
          return "index";
        }

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

        @Override
        protected boolean isNewArchEnabled() {
          return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
        }

        @Override
        protected Boolean isHermesEnabled() {
          return BuildConfig.IS_HERMES_ENABLED;
        }
      };

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

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
    if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
      // If you opted-in for the New Architecture, we load the native entry point for this app.
      DefaultNewArchitectureEntryPoint.load();
    }
    ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
  }
}

Maybe your case is different from mine

@vishpatil1999 post yours so I can compare with mine, since we use different react native versions

vishpatil1999 commented 1 year ago

@pnthach95 , Yes it worked on react native0.68.1 new CodePush(getResources().getString(R.string.CodePushDeploymentKey), getApplicationContext(), BuildConfig.DEBUG); no need to add this line in MainApplication.java file Note : it was mentioned on codepush documentation , they should update there document

riteshjena commented 1 year ago

@vishpatil1999 @pnthach95 I am getting the same issue. By debugging the library I realized that it is looking for a codepush.json file which is missing for me. I went through the documentation but couldn't find any details about where to add this or the necessity of it.

Did either of you add any such file? Any information would be really helpful.

pnthach95 commented 1 year ago

There is no codepush.json file anywhere. Are you sure this is the same issue? What versions of RN and code push you use?

riteshjena commented 1 year ago

Then may be this file is supposed to be generated by the cli when publishing a bundle and for some reason it isn't. The code push library is looking for the file to look for bundle name and match it with the existing bundle name before patching the update

I am on code push v8.1.0 and RN version of 0.71.12

AnatolyPristensky commented 9 months ago

Closing due to the absence of activity.

arifirfan06 commented 9 months ago

I'm using MainApplication.kt how to make change of this code?


import com.microsoft.codepush.react.CodePush;
class MainApplication : Application(), ReactApplication {

  override val reactNativeHost: ReactNativeHost =
      object : DefaultReactNativeHost(this) {
        override fun getPackages(): List<ReactPackage> {
          // Packages that cannot be autolinked yet can be added manually here, for example:
          // packages.add(new MyReactNativePackage());
          return PackageList(this).packages
        }
        override fun getJSMainModuleName(): String = "index"

        override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG

        override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
        override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
}
pnthach95 commented 9 months ago

@arifirfan06

      object : DefaultReactNativeHost(this) {
        ...
        override fun getJSBundleFile(): String = CodePush.getJSBundleFile()
        ...
      }
AjaiNarayananS commented 5 months ago

package com.ajaisagaa.StickerSmash import com.microsoft.codepush.react.CodePush; import android.app.Application import android.content.res.Configuration import com.facebook.react.PackageList import com.facebook.react.ReactApplication import com.facebook.react.ReactNativeHost import com.facebook.react.ReactPackage import com.facebook.react.ReactHost import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load import com.facebook.react.defaults.DefaultReactNativeHost import com.facebook.soloader.SoLoader

import expo.modules.ApplicationLifecycleDispatcher import expo.modules.ReactNativeHostWrapper import com.google.android.gms.ads.MobileAds

import com.microsoft.codepush.react.CodePush;

class MainApplication : Application(), ReactApplication {

override val reactNativeHost: ReactNativeHost = ReactNativeHostWrapper( this, object : DefaultReactNativeHost(this) { override fun getPackages(): List { // Packages that cannot be autolinked yet can be added manually here, for example: // packages.add(new MyReactNativePackage()); return PackageList(this).packages }

      override fun getJSBundleFile(): String = CodePush.getJSBundleFile()

      override fun getJSMainModuleName(): String = ".expo/.virtual-metro-entry"

      override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG

      override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
      override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
  }

)

override val reactHost: ReactHost get() = ReactNativeHostWrapper.createReactHost(applicationContext, reactNativeHost)

override fun onCreate() { super.onCreate() SoLoader.init(this, false) if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { // If you opted-in for the New Architecture, we load the native entry point for this app. load() } ApplicationLifecycleDispatcher.onApplicationCreate(this) MobileAds.initialize(this) {} }

override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig) }

} but im geting this error Conflicting import, imported name 'CodePush' is ambiguous