Cordova plugins not working

前端 未结 3 1988
北海茫月
北海茫月 2020-12-05 15:08

Edit for clarification: The you see in some of the files below is not actually part of the files, but it includes the company name

相关标签:
3条回答
  • 2020-12-05 15:46

    If your plugins don't work you can also try these steps:

    cordova plugin list;
    cordova plugin remove my-cordova-plugin --save;
    cordova plugin add my-cordova-plugin --nosave;
    

    Also be aware of the following plugin dependencies:

    1. The file, file-transfer, and camera plugins are all dependent on the compat plugin; so compat needs to be removed last.
    2. The file-transfer plugin is dependent on file, so file needs to be removed first.
    0 讨论(0)
  • 2020-12-05 15:48

    Today I learned another cause why this can break: Ensure that your project does not have a second file named cordova.js, no matter where. If the cordova plugin management finds such a file included as tag, it can wrongly assume that your own file’s base path is the base path of Cordova’s cordova.js and uses it as base path for loading its own JS files.

    0 讨论(0)
  • 2020-12-05 16:05

    Checklist: Is your plugin loaded?

    • Does your index.html load the cordova.js script? (i.e. if you have www/index.html then you can just reference cordova.js. This file is not in the www directory, but automatically generated by Cordova and inserted in your app)
    • Is the plugin javascript loaded? Use Chrome or Safari to remote debug your android/iOS app.
    • cordova plugin ls: Is your plugin listed?
    • plugins/android.json: Is your plugin listed?
    • Does platforms/android/assets/www have all files? (i.e. a plugins folder with scripts, cordova_plugins.js should mention your plugin, a platform-specific cordova.js)

    Can you listen to the deviceready event to check if Cordova initializes at all? (If all scripts are in place)

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