matteo
matteo

Reputation: 2401

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?

Upvotes: 0

Views: 3700

Answers (3)

starterProgrammer
starterProgrammer

Reputation: 286

Hello i had the same issue when try to build android apk just open

platforms/android/app/src/main/java/com/silkimen/cordovahttp.java

And then Comment all codes commented source

It is working for me :)

Upvotes: 0

Supriya
Supriya

Reputation: 581

Ionic cordova platform rm android
After that add platform
ionic cordova platform add android
Ionic cordova run android

Upvotes: 0

Prashant
Prashant

Reputation: 1385

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

Upvotes: 3

Related Questions