Search code examples
androidcordovacordova-plugins

Cordova Android app force closes after build


Here's the error details:

12-04 22:00:12.087: E/AndroidRuntime(19113): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.package.name.dev/com.package.name.dev.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.cordova.CordovaPlugin.privateInitialize(java.lang.String, org.apache.cordova.CordovaInterface, org.apache.cordova.CordovaWebView, org.apache.cordova.CordovaPreferences)' on a null object reference

Background: I was originally only building the app for Android, but during my last release I had to generate an iOS build as well, which required some extra plugins and configuration tweaks to get functional. Now I'm trying to create a new release for Android, but the new app force closes as soon as it is opened.

In an effort to fix it, I tried to remove all references to the iOS-only plugins from the Android side of the project, but the error persists. I'm not sure what else to try.

What would provoke Cordova to throw this error when initializing plugins?


Solution

  • The issue was that one of the plugins had failed to copy its java classes into the Android app src directory when it was installed. I created the appropriate directory hierarchy and then copied in the java files from the /plugins/ dir.

    To figure out which plugin caused the issue, I disabled the onload param from each feature one at a time (in the android.json file in the android platform directory) until the app successfully opened.