[ERROR] - Error Initializing Cordova: Class not found

Hi All,

I am building an Ionic2 app (2.0.0-beta.32) with Cordova plugins.

cordova-plugin-camera
cordova-plugin-image-picker

I am continually getting the following error when I build the apk and install on my phone when trying to access the plugin functionality:

[ERROR] Error Initializing Cordova: Class not found

I get the following error when trying to access the RESTful services that are available and my phone does have a wifi connection.

Application Error
The connection to the server was unsuccessful. (file:///android_asset/www/index.html)

(I have had the app in the past install correctly via an apk, but don’t know what has changed, so I even built a new app and installed the 2 Cordova plugins, and get the same error again).

I install the android platform:

ionic platform add android

I have even tried installing Cordova again from mt app root.

npm install -g cordova

When I build my apk files, I try bother from the CLI (generates android-release-unsigned.apk):

cordova build --release android

And running build from Ionic Lab (generates android-debug.apk & android-debug-unaligned.apk).

I can only get the android-debug.apk to run on my phone (I haven’t tried installing certificates). The app runs, but gives the above Class not found error.

A strange thing, when I run ionic serve --livereload I can run the app in a browser via http://localhost:8100/, and it looks fine, because I get cordova_not_available as expected, and the app can access the RESTful services.

Questions:

  • Should I be using the android-debug.apk or android-debug-unaligned.apk or android-debug.apk? (I just want to test it, and not have to generate the certificates, so have been trying to use android-debug.apk)

  • Which ones should I use:
    cordova platform add android or ionic platform add android
    cordova build or ionic build (if I don’t build from Ionic Lab?)

When I build, I get (cordova build or ionic build):

BUILD SUCCESSFUL

I have also tried with no sucess:

ionic platform rm android
ionic platform add android

and

cordova platform rm android
cordova platform add android

If anyone could please assist, it would be appreciated.

SOLVED

I run cordova build and deployed the android-debug-unaligned.apk and it works now.

I am not sure if the problem was building with Ionic lab, or using the ionic build command, but if I just stick to the cordova commands, it seems to work for me.

2 Likes