我安装了PhoneGap 3.x,并且一直在使用命令行API来构建我的Android应用程序。
我需要访问联系人等一些硬件功能,因此我使用API来安装插件。但是,当我列出已安装的插件时,找不到任何插件,并且未定义导航器上的联系人对象。
这是命令行命令:
BUILD SUCCESSFUL
Total time: 2 minutes 3 seconds
[phonegap] successfully compiled Android app
phonegap plugin list
[phonegap] no plugins installed
phonegap local plugin add org.apache.cordova.contacts
[phonegap] adding the plugin: org.apache.cordova.contacts
[phonegap] successfully added the plugin
phonegap plugin list
[phonegap] no plugins installed
我尝试删除插件文件夹内容,然后重新创建我的Android平台,然后尝试重新添加插件,但没有运气。
插件位于plugins文件夹中,看起来像是正确的内容,插件文件夹中有一个android.xml文件,但由于某些原因,PG没有看到插件已安装。
我使用的是Windows 7,phonegap ver 3.5.0-0.20.4
答案 0 :(得分:1)
Mac OS上的相同问题,phonegap v3.5.0-0.20.4
问题来自文件 lib / phonegap / local.plugin.list.js 中的错误,其中插件的返回列表不正确。
LocalPluginListCommand.prototype.listPlugins = function(plugins, callback) {
var self = this,
e = null;
// error is not supported by cordova, but this is for the future
if (plugins instanceof Error) {
e = plugins;
plugins = [];
self.phonegap.emit('error', e);
} else if (typeof plugins === 'string') {
// identify the "no plugins" response to phonegapify the output
if (plugins.indexOf('No plugins added') > -1) {
plugins = [];
self.phonegap.emit('log', 'no plugins installed');
}
else {
// list plugins
self.phonegap.emit('log', plugins);
}
}
callback(e, plugins);
};
以下是错误文件的官方更正: https://github.com/phonegap/phonegap-cli/commit/d8d54ece21300dad63015779b6c5c629510c17d6