Cordoba initialization error: class not found

I followed the Phonegap tutorial from the official Phonegap.com website (starting with Android).

I created a project with the following steps.

  • created activity and expanded with "DroidGap" and added the loadURL method from onCreate ().
  • Added cordova-2.0.0.js and cordova-2.0.0.jar to the corresponding folder.
  • Added jar file to build path
  • Uploaded js file from html tag
  • Added permissions from AndroidMainfeast.xml
  • copied the xml folder containing "configs.xml"

Now I do not understand where the problem is. It shows the error below as shown in the screenshot enter image description here

Here is my HTML file

<!DOCTYPE html> <html> <head> <title>Notification Example</title> <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script> <script type="text/javascript" charset="utf-8"> // Wait for Cordova to load // document.addEventListener("deviceready", onDeviceReady, false); // Cordova is ready // function onDeviceReady() { // Empty } // Show a custom alert // function showAlert() { navigator.notification.alert( 'You are the winner!', // message 'Game Over', // title 'Done' // buttonName ); } // Beep three times // function playBeep() { navigator.notification.beep(3); } // Vibrate for 2 seconds // function vibrate() { navigator.notification.vibrate(2000); } </script> </head> <body> <p><a href="#" onclick="showAlert()">Show Alert</a></p> <p><a href="#" onclick="playBeep()">Play Beep</a></p> <p><a href="#" onclick="vibrate()">Vibrate</a></p> </body> </html> 

Any tips? Thank!

+53
android cordova
Aug 13 '12 at 13:13
source share
12 answers

This is config.xml not configs.xml .

Based on the logs, I see that you are missing this file in the res/xml application directory. It is included as part of the distribution in lib/android/res/xml/config.xml , so copy this file to the res/xml directory and you should all be installed.

+63
Aug 13 2018-12-17T00:
source share
— -

Just like aharris88 in answer to this question , I got the error message [CORDOVA] Error initilizing Cordova: Class not found when using Cordova 3.1.0 on my Android dev phone after switching from Phonegap 3.0.

All attempts using the config.xml file in the /platforms/android/res/xml directory did not help. Based on the above Stackoverflow answer, I tried to “get started” by reinstalling Android platform support:

 cordova platform rm android cordova platform add android 

After this step, it worked again, and I was able to cordova build android && cordova run android without any additional problems.

+37
Oct 19 '13 at 16:41
source share

I had this error due to a plugin that I removed. I added

 <plugin name="Device" value="org.apache.cordova.Device"/> 

to the config.xml file and he fixed it.

+10
May 20 '13 at 22:28
source share

I do not have the following plugin:

 <plugin name="Device" value="org.apache.cordova.Device"/> 

You must install this between <plugins></plugins> . as

 <plugins> <plugin name="Device" value="org.apache.cordova.Device"/> </plugins> 
+7
Jul 19. '13 at 8:29
source share

Well, I found an error:

05-28 08: 19: 53.139: E / PluginManager (1478): ================================== =================================================== ==== 05-28 08: 19: 53.139: E / PluginManager (1478): ERROR: config.xml is missing. Add res / xml / config.xml to your project. 05-28 08: 19: 53.139: E / PluginManager (1478): https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.git;a=blob;f= framework / res / xml / plugins.xml

but I found /res/xml/config.xml in my project

Finally, I found an error in org.apache.cordova.api.PluginManager:

 public void loadPlugins() { int id = this.ctx.getActivity().getResources().getIdentifier("config", "xml", this.ctx.getActivity().getClass().getPackage().getName()); ... 

should change to:

 public void loadPlugins() { int id = this.ctx.getActivity().getResources().getIdentifier("config", "xml", this.ctx.getActivity().getPackageName()); ... 

you can learn more about the method "getIdentifier (String name, String defType, String defPackage)" in the white paper

+6
May 28 '14 at 9:53
source share

I had this problem using phonegap 3.x, and the problem turned out to be that the plugins were incorrectly installed in the phone splash screen, or they just messed up along the way. Basically, when you install plugins and build for the platform, it takes javascript files from /org.apache.cordova.core.specific-plugin/www plugins and puts them in /android/assets/www/plugins/org.apache platforms. cordova.core.specific-plugin / www, and then it takes Java files (or object C for iOS) and puts them in the platforms / android / src / org / apache / cordova / specificplugin

And all this is indicated by the /org.apache.cordova.core.specific-plugin/plugin.xml plugins. If you look in the plugins.xml file, you will see something like:

 <source-file src="src/android/NetworkManager.java" target-dir="src/org/apache/cordova/networkinformation" /> 

So this tells you that in the platforms / android / src / org / apache / cordova / networkinformation there should be NetworkManager.java. And this file can be copied from /org.apache.cordova.core.network-information/src/android/NetworkManager.java plugins

Now all this should happen automatically without having to touch the platforms folder. But if it goes bad, you can fix it by manually copying the right files to the right folders.

+5
Sep 18 '13 at 23:42 on
source share

You can solve this problem using the phonegap command line by following these steps:

  • Delete merges / android, platform / android, plugins / android.json

  • run phonegap local build android

+2
Apr 10 '14 at 16:08
source share

Whether the same problem with the class was not found. One problem to look at is to make sure that the android.json (or ios.json) file is updated in the assembly. The mine was virtually empty. Also, remove and add plugins as indicated in some other posts. Finally, what worked for me was to make sure the plugins were fixed in the config.xml file:

 <feature name="Device"> <param name="android-package" value="org.apache.cordova.device.Device"/> </feature> <feature name="Camera"> <param name="android-package" value="org.apache.cordova.camera.CameraLauncher"/> </feature> <feature name="Notification"> <param name="android-package" value="org.apache.cordova.dialogs.Notification"/> </feature> 

Note the double designation "device.Device", as well as a subclass for the plugins "camera" and "dialogs". This incorrectly refers to the Phonegap documentation.

+2
May 09 '14 at 15:35
source share

I came across the same error: “Cordoba initialization error: class not found”, using Cordova with visual studio 2015. But this was not the only error, none of my plugins seemed to get into the trough. I tried EVERYTHING. From cordova platform rm/add android x1000 times, to removing and re-adding plugins manually, nothing seems to do the trick.

enter image description here

Then I changed my cordova-cli in the taco.json file from 5.3.3 to 5.4.0 and ran it on my device. Finally, this is all for me. Then I downgraded the cordova version to 5.3.3 (version 5.4.0 is still not supported by the adb bridge). Give it a try!

+1
Jan 25 '16 at 9:40
source share

[Solved in my case]

Firstly, step six is ​​wrong: this is config.xml, not configs.xml

I have the same error even though I have config.xml in the res / xml folder. This is because you need to install plugins manually for the core API functions.

Go to the project folder through the console and enter:

 phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git 

You can read more here in the Doc Phonebook (the last section, called adding features): Phone Dock

I also leave the config.xml file

 <?xml version='1.0' encoding='utf-8'?> <widget id="io.cordova.helloCordova" version="2.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0"> <name short="Menu">Menu Digital</name> <description> Description </description> <author email="asd@gmail.com" href="www.facebook.com/usr"> Name </author> <feature name="App"> <param name="android-package" value="org.apache.cordova.App" /> </feature> <feature name="http://api.phonegap.com/1.0/device" /> <feature name="http://api.phonegap.com/1.0/media" /> <feature name="Device"> <param name="android-package" value="org.apache.cordova.device.Device" /> </feature> <content src="index.html" /> <feature name="App"> <param name="android-package" value="org.apache.cordova.App" /> </feature> <access origin="*" /> <preference name="useBrowserHistory" value="true" /> <preference name="exit-on-suspend" value="false" /> <preference name="fullscreen" value="true" /> <preference name="webviewbounce" value="true" /> </widget> 
0
Nov 01 '13 at 4:47
source share

I get the same error, I checked the list of plugins in Cordoba

by running the "cordova plugin list" command in my Android project project and finding that the plugin "org.apache.cordova.device" is missing.

I updated it using the "Cordova add cordova-plugin-device" plugin and the error went away.

0
Jul 28 '15 at 7:55
source share

So, after I killed myself, I found that I used the version of cordova 5.3.3 and the version-cordova-version of Android 5.0.0, somehow I don’t know, maybe they are incompatible or there may be an error, so I back to cordova android 4.1.1

  cordova platform rm android cordova platform add android@4.1.1 

and it saved me.

0
Nov 17
source share



All Articles