Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic app runs in browser, but fails on Android: [ERROR] Error initializing Cordova: Class not found

My App is based on the Ionic sidemenu starter project. It works fine in a browser, but trying to run it on my Android device results in an alert with the following message:

[ERROR] Error initializing Cordova: Class not found

I tried the suggested solutions in this post, but none of them solved the issue.

To reproduce the issue, please follow the instructions here.

Any ideas what's going on?


Some info:

$ cordova --version
3.5.0-0.2.6

$ ionic --version
Installed Ionic CLI version: 1.1.1-beta3

# In browser's console
> ionic.version === "1.0.0-beta.9"

Related question: ui-router resolve behaves strangely in Ionic

like image 861
Misha Moroshko Avatar asked Mar 19 '23 00:03

Misha Moroshko


1 Answers

I've had this error before. It can be tricky since it is super generic. I'm not sure if this is related, but after much trouble I was able to resolve my problem using these steps:

  1. Make a backup of the .json files inside of your /plugins directory.
  2. Remove the .json files in your /plugins directory.
  3. Empty your platform directories.
  4. Re-add the platforms you want.
  5. Build your app again.

Also, I have my cordova.js at the very bottom of my body tag, not in the head as I've seen suggested elsewhere. Your mileage may vary.

like image 68
JimTheDev Avatar answered Mar 23 '23 00:03

JimTheDev