Closed vishpatil1999 closed 9 months ago
I have same issue on RN 0.72
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.
@pnthach95 Can you pplease share your source code
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;
}
};
@pnthach95 Please share whole code as I already added getJSBundleFile() in MainApplication.java . Still getting same issue
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
@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
@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.
There is no codepush.json file anywhere. Are you sure this is the same issue? What versions of RN and code push you use?
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
Closing due to the absence of activity.
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
}
@arifirfan06
object : DefaultReactNativeHost(this) {
...
override fun getJSBundleFile(): String = CodePush.getJSBundleFile()
...
}
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
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
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
Reproducible Demo
Examples
folder runnode create-app.js appName react-native@0.61.5 react-native-code-push@6.0.0
command to generate plain CodePushified React Native app. Please see description on top ofcreate-app.js
file content if neededEnvironment
(The more info the faster we will be able to address it!)