Error initializing Cordova: Class not found

后端 未结 13 1402
清歌不尽
清歌不尽 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:28

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

    And all of this is specified by plugins/org.apache.cordova.core.specific-plugin/plugin.xml. If you look in a plugins.xml you should see something like:

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

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

    Now all of this is supposed to happen automatically without having to touch the platforms folder. But if it messes up you can fix it by manually copying the correct files into the correct folders.

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

    This could happened 'cause your cordova plugin have a different path from what IONIC expect to found:

    You should correct the file plugin.xml inside your plugin source folder:

    <config-file target="app/src/main/res/xml/config.xml" parent="/*">
    

    should be:

     <config-file target="res/xml/config.xml" parent="/*">
    

    If you try to searching that error inside the Android Studio Logcat usually you find something like:

    io.ionic.starter E/chromium: [ERROR:service_manager.cc(156)] Connection InterfaceProviderSpec prevented service: content_renderer from binding interface: blink::mojom::BudgetService exposed by: content_browser
    2019-02-22 13:40:06.144 30230-30258/com.android.webview:sandboxed_process0 E/chromium: [ERROR:BudgetService.cpp(167)] Unable to connect to the Mojo BudgetService.
    
    0 讨论(0)
  • I'm getting the same error, I checked my Cordova plugin list

    by running the command "cordova plugin list" in my Android project directory and found "org.apache.cordova.device" plugin missing.

    I updated it using "Cordova plugin add cordova-plugin-device" and Error was gone.

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

    So After near to kill myself , i found that i was using cordova version 5.3.3 and cordova-android version 5.0.0, somehow i don't know may be there are not compatible or there can be a bug ,so i fall back to cordova android 4.1.1

      cordova platform rm android
      cordova platform add android@4.1.1 
    

    and this saved me up

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

    I have had this error because of a plugin that I deleted. I Added

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

    to the config.xml file again and it fixed it.

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

    Had same problem with Class not found. One problem to look at is to ensure that the android.json (or ios.json) file is being updated on a build. Mine was effectively empty. Also, remove and add back the plugins as mentioned in some other posts. Finally, the thing that worked for me was to ensure that the plugins were corrected referenced in the config.xml:

    <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 naming of 'device.Device' and also the sub-classing of the 'camera' and 'dialogs' plugins. This just isn't properly referenced by the Phonegap documentation.

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