不可能为Android构建Ionic

时间:2018-03-28 12:21:48

标签: cordova ionic-framework cordova-plugins

我正在尝试为Android编译一个离子应用程序,但是我收到一个错误:

$ ionic cordova build android
..............................
/home/matte/Desktop/Cimoda/platforms/android/src/com/synconset/cordovahttp/CordovaHttpDownload.java:18: error: package org.apache.cordova.file does not exist
import org.apache.cordova.file.FileUtils;
                              ^
/home/matte/Desktop/Cimoda/platforms/android/src/com/synconset/cordovahttp/CordovaHttpDownload.java:49: error: cannot find symbol
                JSONObject fileEntry = FileUtils.getFilePlugin().getEntryForFile(file);
                                       ^
  symbol:   variable FileUtils
  location: class CordovaHttpDownload
..............................
[ERROR] An error occurred while running cordova build android (exit code 1).

这是关于该项目的package.json的cordova的参与者:

"cordova": {
    "plugins": {
        "cordova-plugin-advanced-http": {},
        "cordova-plugin-device": {},
        "cordova-plugin-ionic-keyboard": {},
        "cordova-plugin-ionic-webview": {},
        "cordova-plugin-splashscreen": {},
        "cordova-plugin-whitelist": {},
        "cordova-plugin-file": {}
    },
    "platforms": [
        "android"
    ]
}

cordova-plugin-file插件是由离子构建自动添加的。 你知道我怎么解决吗?

2 个答案:

答案 0 :(得分:3)

请重新卸载并重新安装。它将更新到更新的版本。这有助于我解决类似的问题。

$ ionic cordova plugin remove cordova-plugin-file

然后

$ ionic cordova plugin add cordova-plugin-file
$ npm install --save @ionic-native/file

答案 1 :(得分:0)

离子Cordova平台rm android
之后添加平台
离子Cordova平台添加android
离子科尔多瓦运行android