Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

[QUESTION] NullPointerException #36

@tomasz-nowak

Description

@tomasz-nowak

Hey,
when I'm trying to run app with react-native-cordova-plugin, it builds properly, but crashes instantly after run on tablet / emulator ("Unfortunately, has stopped.").
Android monitor in android studio throws that error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.appname/com.appname.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void io.cordova.reactnative.CordovaPluginPackage.setSavedInstanceState(android.os.Bundle)' on a null object reference.

My MainActivity.java:
(...imports...)
public class MainActivity extends ReactActivity {

/**
 * Returns the name of the main component registered from JavaScript.
 * This is used to schedule rendering of the component.
 */
@Override
protected String getMainComponentName() {
    return "appname";
}

protected List<ReactPackage> getPackages() {
 return Arrays.<ReactPackage>asList(
         new MainReactPackage(),
         cordovaPluginPackage = new CordovaPluginPackage(this)
 );
}
private CordovaPluginPackage cordovaPluginPackage;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    cordovaPluginPackage.setSavedInstanceState(savedInstanceState);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    cordovaPluginPackage.onActivityResult(requestCode, resultCode, intent);
}

}

I deleted the @OverRide keyword from getPackages() because it didn't compile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions