我正在开发一个需要 Android Downloader 插件的 phonegap 应用程序:https ://github.com/phonegap/phonegap-plugins/tree/master/Android/Downloader
不幸的是,使用最新的cordova(2.2)似乎失败了。我花了几个小时试图升级代码:
下载器.js
cordova.define(
"cordova/plugin/downloader",
function(require, exports, module)
{
var exec = require("cordova/exec");
var Downloader = function() {};
Downloader.prototype.downloadFile = function(fileUrl, params, successCallback, failureCallback)
{
// Make params hash optional.
if (!failureCallback) win = params;
return exec(
successCallback,
failureCallback,
'Downloader',
'downloadFile',
[fileUrl, params]);
};
var downloader = new Downloader();
module.exports = downloader;
}
);
下载器.java
package org.apache.cordova.plugins.Downloader;
import org.apache.cordova.api.CordovaInterface;
import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
[more imports...]
public class Downloader extends Plugin
{
etc.
配置文件
<plugins>
<plugin name="App" value="org.apache.cordova.App"/>
[...]
<plugin name="Downloader" value="org.apache.cordova.plugins.Downloader"/>
</plugins>
HTML JS 调用
downloader = cordova.require("cordova/plugin/downloader");
downloader.downloadFile(...
该应用程序在 Eclipse 中编译得很好,但是在执行下载器代码时我得到:ALERT Class not found。日志猫说:
W/System.err(4035): java.lang.ClassNotFoundException: org.apache.cordova.plugins.Downloader ... 添加插件 org.apache.cordova.plugins.Downloader 时出错。
你能帮我解决什么问题吗?