iOS side is working, can't get the android side to work.
Load bundle from localhost Dev Server when running debug build
What actually happens?

MainApplication.java
package com.example;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.facebook.react.ReactInstanceManager;
import com.reactnativenavigation.NavigationApplication;
import com.reactnativenavigation.react.NavigationReactNativeHost;
import com.reactnativenavigation.react.ReactGateway;
import com.microsoft.codepush.react.CodePush;
import java.util.Arrays;
import java.util.List;
import android.util.Log;
public class MainApplication extends NavigationApplication {
@Override
protected ReactGateway createReactGateway() {
ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) {
@javax.annotation.Nullable
@Override
protected String getJSMainModuleName() {
return CodePush.getJSBundleFile();
}
};
return new ReactGateway(this, isDebug(), host);
}
@Override
public boolean isDebug() {
return BuildConfig.DEBUG;
}
protected List<ReactPackage> getPackages() {
// Add additional packages you require here
// No need to add RnnPackage and MainReactPackage
return Arrays.<ReactPackage>asList(
// eg. new VectorIconsPackage()
new CodePush("REDACTED", getApplicationContext(), isDebug())
);
}
@Override
public List<ReactPackage> createAdditionalReactPackages() {
return getPackages();
}
}
return CodePush.getJSBundleFile(); is returning
: assets://index.android.bundle
It was a gradle issue
@eaco-andrew how to fix the problem ?
@eaco-andrew , Do you have any suggestions?
@xuananpham93 ,I finally solve this problem by adding getJSBundleFile in ReactNativeHost:
public class MainApplication extends NavigationApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNDeviceInfo(),
new SvgPackage(),
new RNFirebasePackage(),
new CodePush("KEY", getApplicationContext(), BuildConfig.DEBUG)
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
@maleking, thanks for your response. I added this to my code but not work
@xuananpham93 i edited previous comment hope it works
@maleking , are you sure you are using react-native-navigation? Maybe you not
@xuananpham93, yes absolutely 馃槃
( "react-native": "0.59.8","react-native-code-push": "^5.6.0","react-native-navigation": "^2.18.5")
@maleking maybe you have react-native-navigation installed but as far as I can see in your code you are not using it. MainApplication should extend NavigationApplication.
@buskerone yes your are right , my code that i commented was wrong but in my app it is correct and works
@maleking Can you show your MainApplication.java. I have same issue with RNN2
UPDATE: I have addded @Override
protected String getJSMainModuleName() {
return "index";
}
And now I passed this error but gets https://github.com/microsoft/react-native-code-push/issues/1272
@rendomnet
public class MainApplication extends NavigationApplication {
protected ReactGateway createReactGateway() {
ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) {
@javax.annotation.Nullable
@Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
return new ReactGateway(this, isDebug(), host);
}
@Override
public boolean isDebug() {
return BuildConfig.DEBUG;
}
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new RNGestureHandlerPackage(),
new MainReactPackage(),
new FastImageViewPackage(),
new CodePush("KEY", getApplicationContext(), BuildConfig.DEBUG)
);
}
@Override
public List<ReactPackage> createAdditionalReactPackages() {
return getPackages();
}
}
Android, I try open access about write and read file, then test it in dev again. this error didn't happen.
Most helpful comment
@rendomnet