Skip to content Skip to sidebar Skip to footer

Android “[error] Error Initializing Cordova: Class Not Found”

I am using phonegap-2.9.0 I copied xml folder from android/example/res/ and paste it into /res Still i am getting following alert in emulator screen “[ERROR] Error initializing C

Solution 1:

I think you have not add config.xml file in your project.Here what you should do.. 1. Create a new folder name 'xml' in the res directory of your project 2. go to the lib/android/framework/res/xml directory of the Phonegap folder then copy the config.xml file to your project's xml folder. I hope this will do for you

Solution 2:

If you are using phonegap CLI from different machines, such as from MacOS and windows, you may see similar error. You need to remove and reinstall necessary plugins in current machine. For example, I had following error in my Windows 8 Machine.

11-0606:05:52.410: W/System.err(989): java.lang.ClassNotFoundException: org.apache.cordova.device.Device
11-0606:05:52.420: W/System.err(989):  at java.lang.Class.classForName(Native Method)
11-0606:05:52.430: W/System.err(989):  at java.lang.Class.forName(Class.java:251)
11-0606:05:52.430: W/System.err(989):  at java.lang.Class.forName(Class.java:216)
11-0606:05:52.430: W/System.err(989):  at org.apache.cordova.PluginEntry.getClassByName(PluginEntry.java:117)
11-0606:05:52.430: W/System.err(989):  at org.apache.cordova.PluginEntry.createPlugin(PluginEntry.java:93)
11-0606:05:52.440: W/System.err(989):  at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:278)
11-0606:05:52.440: W/System.err(989):  at org.apache.cordova.PluginManager.execHelper(PluginManager.java:232)
11-0606:05:52.440: W/System.err(989):  at org.apache.cordova.PluginManager.exec(PluginManager.java:227)
11-0606:05:52.440: W/System.err(989):  at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:53)
11-0606:05:52.440: W/System.err(989):  at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)

Use following commands to fix error for this case.

 phonegap local plugin remove org.apache.cordova.device
 phonegap local plugin add org.apache.cordova.device

These commands change only following file plugins\org.apache.cordova.device.fetch.json.

@@ -1,1+1,1 @@
-{"source":{"type":"local","path":"/var/folders/v4/gn4xwpg91cgcmjc9psw86y7m0000gp/T/org.apache.cordova.device/package"}}
\ No newline at end of file
+{"source":{"type":"local","path":"C:\\Users\\ATILLA~1.OZG\\AppData\\Local\\Temp\\org.apache.cordova.device\\package"}}
\ No newline at end of file

After that this error in my case, goes away.

Solution 3:

I had this problem; even after showing the error the app worked, including most of the plugins. But the plugin "org.apache.cordova.device" didn't work so I removed it from the project, then the 'initializing Cordova' error went away. So something incompatible or at fault with the plugin, but don't know what as yet. (Using Cordova 3.5 with Android)

Solution 4:

The issue is with the PluginManager class. Replace the below code (phonegap v2.9.1)

/**
 * Load plugins from res/xml/config.xml
 */publicvoidloadPlugins() {
    int id = this.ctx.getActivity().getResources().getIdentifier("config", "xml", this.ctx.getActivity().getClass().getPackage().getName());
   ......
}

with

publicvoidloadPlugins() {
        int id = this.ctx.getActivity().getResources().getIdentifier("config", "xml",  this.ctx.getActivity().getPackageName());
    ........
}

You can find the plugin manager class in this package

org.apache.cordova.api.PluginManager

Post a Comment for "Android “[error] Error Initializing Cordova: Class Not Found”"