0

我正在尝试将此插件添加到 PhoneGap 应用程序。

我使用了这个命令:

$ cordova plugin add cordova-media-with-compression

我可以看到插件正确添加到运行此插件的列表中:

$ phonegap plugin list

但是当我使用PhoneGap Developer App(在 iPhone 上)时,插件不可用。

我正在运行此代码以在运行时获取已安装插件的列表

document.addEventListener("deviceready", function () {

  var pluginList = cordova.require("cordova/plugin_list").metadata;
  console.log(JSON.stringify(pluginList));

});

如果我从浏览器或 PhoneGap Developer App 运行应用程序,上面的代码会返回两组不同的插件。从浏览器我得到这个:

{
  "cordova-media-with-compression": "2.1.0",
  "cordova-plugin-battery-status": "1.1.2",
  "cordova-plugin-camera": "2.1.1",
  "cordova-plugin-compat": "1.1.0",
  "cordova-plugin-console": "1.0.4",
  "cordova-plugin-contacts": "2.0.1",
  "cordova-plugin-device": "1.1.3",
  "cordova-plugin-device-motion": "1.2.2",
  "cordova-plugin-device-orientation": "1.0.4",
  "cordova-plugin-dialogs": "1.2.1",
  "cordova-plugin-file": "4.3.0",
  "cordova-plugin-file-transfer": "1.5.1",
  "cordova-plugin-geolocation": "2.1.0",
  "cordova-plugin-globalization": "1.0.4",
  "cordova-plugin-inappbrowser": "1.3.0",
  "cordova-plugin-network-information": "1.2.1",
  "cordova-plugin-splashscreen": "3.2.2",
  "cordova-plugin-statusbar": "2.1.3",
  "cordova-plugin-vibration": "2.1.2",
  "cordova-plugin-whitelist": "1.2.2"
}

PhoneGap Developer App我得到这个:

{
  "com.wikitude.phonegap.WikitudePlugin": "5.3.0",
  "cordova-plugin-battery-status": "1.2.0",
  "cordova-plugin-ble-central": "1.1.2",
  "cordova-plugin-camera": "2.3.0",
  "cordova-plugin-compat": "1.0.0",
  "cordova-plugin-console": "1.0.4",
  "cordova-plugin-contacts": "2.2.0",
  "cordova-plugin-device": "1.1.3",
  "cordova-plugin-device-motion": "1.2.2",
  "cordova-plugin-device-orientation": "1.0.4",
  "cordova-plugin-dialogs": "1.3.0",
  "cordova-plugin-file": "4.3.0",
  "cordova-plugin-file-transfer": "1.6.0",
  "cordova-plugin-geolocation": "2.4.1-dev",
  "cordova-plugin-globalization": "1.0.4",
  "cordova-plugin-inappbrowser": "1.5.0",
  "cordova-plugin-insomnia": "4.2.0",
  "cordova-plugin-media": "2.4.0",
  "cordova-plugin-media-capture": "1.4.0",
  "cordova-plugin-network-information": "1.3.0",
  "cordova-plugin-splashscreen": "4.0.0",
  "cordova-plugin-statusbar": "2.2.0",
  "cordova-plugin-whitelist": "1.3.0",
  "cordova-plugin-x-socialsharing": "5.1.3",
  "phonegap-plugin-barcodescanner": "6.0.3",
  "phonegap-plugin-contentsync": "1.2.5",
  "phonegap-plugin-mobile-accessibility": "1.0.4",
  "phonegap-plugin-push": "1.8.3"
}

如您所见,在第一个列表中有插件cordova-media-with-compression,而在第二个列表中没有。

为什么两个插件列表不相等?我怎样才能在PhoneGap 开发者应用程序中获得新安装的插件?

4

1 回答 1

1

我发现Phonegap 开发者应用程序带有一组开箱即用的插件,并且无法添加其他外部插件:http ://docs.phonegap.com/references/developer-app/troubleshoot-faq/

如果您在项目中使用了此列表中未显示的插件,则它不适用于开箱即用的 PhoneGap 开发者应用程序。但是,您可以在本地创建自己的 PhoneGap Developer 应用程序的自定义构建,并在其中包含任何其他插件。

官方建议是创建开发者应用程序的自定义构建。

这些是github上关于这个问题的一些讨论:

https://github.com/phonegap/phonegap-app-developer/issues/247 https://github.com/phonegap/phonegap-app-developer/issues/209

于 2016-11-19T08:58:28.603 回答