I am new to React-Native. I was integrating my existing Android native app with react native app. The react native part after running app is showing this error:
null is not an object (evaluating 'C.State') unknown index.android.bundle
Here is the screenshot of the error: Screenshot of error message
I know that this error message comes every time I use react-navigation and react-native-gesture-handler.
Here is the code for package.json file:
{
"name": "Demo",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.6.3",
"react-native": "^0.58.3",
"react-native-gesture-handler": "^1.0.15",
"react-navigation": "^3.1.4"
},
"devDependencies": {
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "24.0.0",
"jest": "24.0.0",
"metro-react-native-babel-preset": "0.51.1",
"react-test-renderer": "16.6.3"
},
"jest": {
"preset": "react-native"
}
}
Here is the native activity that renders the react-native module:
public class MyReactActivity extends Activity implements DefaultHardwareBackBtnHandler {
private ReactRootView mReactRootView;
private ReactInstanceManager mReactInstanceManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModulePath("index.android")
.addPackage(new MainReactPackage())
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
Bundle initialProps = new Bundle();
String str = MainActivity.getMovieID();
initialProps.putString("movie_id", str);
mReactRootView.startReactApplication(mReactInstanceManager, "AwesomeProject", initialProps);
setContentView(mReactRootView);
}
Observe the index.android.bundle written in above code.
Also before running the app I run this command to resolve the Unable to load script from assets index.android.bundle
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
Here too observe that something is being done at index.android.bundle
Can't find anything related to this error. Any help will be appreciated. Thanks.