"[ERROE] Error initializing Cordova: Class not found" only on Android

Hi guys:
My app works well on iOS.
However, when I install it to android, this error will show.
does any one have the same problem?
Is there any way to see the error log on device?

1 Like

— try this below
cordova platform rm android
cordova platform add android

3 Likes

Thanks, I think your way can work .
I fixed it by this:

  1. run adb logcat to see the log
  2. in the log I can see the device plugin cannot be found. (indeed it was there)
  3. I remove all the plugins in platforms/android
  4. build again, and it’s gone.
1 Like

This worked for me:

cordova platform rm android
cordova platform add android

Just deleting the platforms/android folder did NOT work. I guess there is more to it.

Back to work, thanks.

4 Likes

Hi guys:

While building Android app I got exactly the same error several times.
In general three things may cause this error from my experiences.

1.) The plugin you added is missing tag in platforms/android/res/xml/config.xml . Ensure you manually add it or your big grunt brother add it for you.
2.) Your added plugin is not installed in plugins folder, be sure they are existed there before build apk.
3.) If you’re yo fans like me, you probably use https://github.com/diegonetto/generator-ionic this handy generator to speed up your development. For using such tool you should aware of the commands you use need to be aligned the same.(Well…What does that mean?)
Simply speaking, For example: If you use cordova command sets like Ionic docs mentioned, then you should use cordova command sets for all the actions. (e.g. cordova plugin add, cordova build, cordova run…etc). Don’t mix them up with phonegap or grunt together! I had a hard time to figure out root issues until I realized I mixed them up then screwed it up!

All in all, u should stay in the same pipeline saying example of mine that using generator-ionic you should use:

grunt platform:add:android (Create android project and initialize environment)
grunt plugin:add:https://github.com/phonegap-build/PushPlugin.git (Add GCM plugin)
grunt build (Minify and merge html/css/js ,blah blah…togetehr)
grunt run:android (Push .apk to your Android phone)

I was used ionic run android instead of ‘grunt run:android’ ! and of course screwed me up! Hopefully, it helps to everyone struggling this error.

I had the same problem and I fix when I installed cordova in the same directory of my app.

How did you do that?

$ ionic start myApp tabs
$ cd myApp
$ npm install cordova
$ ionic platform add android/ios
$ ionic build android/ios
$ ionic run/emulate android/ios

https://dl.dropboxusercontent.com/u/57366/app.PNG

Excellent! Thank you.

This worked for me too thanks!

Worked for me as well :slight_smile: thank you!

Thank you so much!

I was having a issue where the Photo Library of the iOS version just wouldn’t open, even If i did remove the folder. Now it’s working fine. :smile:

Still relevant and worked for me as well, Thanks!!!

Thanks, this worked for me as well.

Your Solution worked for me, Thank you!

I had the same problem and This worked for me:

ionic cordova platform rm android
ionic cordova platform add android