Error initializing Cordova: Class not found

后端 未结 13 1400
清歌不尽
清歌不尽 2020-12-14 00:09

I followed the tutorial of Phonegap from the official Phonegap.com site (getting started with Android).

I have created project with following all the steps.

相关标签:
13条回答
  • 2020-12-14 00:15

    I ran into the same error: "Error initializing Cordova: Class not found", using cordova with visual studio 2015. But this wasn't the only error, none of my plugins seem to get trough. I've tried about EVERYTHING. From cordova platform rm/add android x1000 times, to deleting and re-adding the plugins manually, nothing seem to do the trick.

    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 fixed the whole issue for me. I then downgraded the cordova version back to 5.3.3 ( the 5.4.0 version is not supported by the adb bridge as of yet ). Try it out!

    0 讨论(0)
  • 2020-12-14 00:17

    You can resolve this when using phonegap command line by doing the following:

    1. Delete merges/android, platforms/android, plugins/android.json

    2. run phonegap local build android

    0 讨论(0)
  • 2020-12-14 00:18

    [Solved in my case]

    First, step six is wrong: it is config.xml and not configs.xml

    I have the same error despite I have my config.xml in res/xml folder. It is because you have to install manually plugins for basic API functions.

    Through console navigate to your project folder and type:

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

    You can read more here in phonegap Doc (last section called add features) : Phonegap Doc

    I leave you also my 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 讨论(0)
  • 2020-12-14 00:19

    My you not have following plugin:

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

    You have to put that in between <plugins></plugins>. like

    <plugins>
        <plugin name="Device" value="org.apache.cordova.Device"/>
    </plugins>
    
    0 讨论(0)
  • 2020-12-14 00:22

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

    All fiddling with the config.xml file in the /platforms/android/res/xml directory did not help. Based on the Stackoverflow answer mentioned above, I tried to "start over" 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 further problems.

    0 讨论(0)
  • 2020-12-14 00:25

    Well,the error I found is:

    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 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 could read more about the method "getIdentifier(String name, String defType, String defPackage)" in offical doc

    0 讨论(0)
提交回复
热议问题