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

[QUESTION] NullPointerException #36

Open
tomasz-nowak opened this issue Jan 13, 2017 · 0 comments
Open

[QUESTION] NullPointerException #36

tomasz-nowak opened this issue Jan 13, 2017 · 0 comments

Comments

@tomasz-nowak
Copy link

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.

@tomasz-nowak tomasz-nowak changed the title NullPointerException [QUESTION] NullPointerException Jan 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant