cordovaionic-frameworkcordova-plugins

Impossible build Ionic for Android


I'm trying to compile an ionic app for android, but I get an error:

$ 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).

this is the parte about cordova of package.json of the project:

"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"
    ]
}

the cordova-plugin-file plugin was added automatically by the ionic build. do you know how I can solve?


Solution

  • Please uninstall and install it again. It will update to newer version. That has helped me before with similar problem.

    $ ionic cordova plugin remove cordova-plugin-file
    

    and then

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