3
votes

My ionic info environment:

cli packages: (C:\Users\jessica\AppData\Roaming\npm\node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 8.0.0

local packages:

@ionic/app-scripts : 3.0.1
Cordova Platforms  : android 6.2.3 browser 5.0.1
Ionic Framework    : ionic-angular 3.8.0

System:

Android SDK Tools : 25.2.5
Node              : v6.10.3
npm               : 6.0.1
OS                : Windows 8.1

Environment Variables:

ANDROID_HOME : C:\Program Files (x86)\Android\android-sdk

Misc:

backend : legacy`

After installing ionic cordova plugin add cordova-plugin-file-transfer, I am getting below error when I run the command ionic cordova build android

:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). F:\D\IONIC\quicktask\quicktask-android\quicktask\platforms\android\src\org\apache\cordova\filetransfer\FileTransfer.java:49: error: package org.apache.cordova.file does not exist import org.apache.cordova.file.FileUtils; ^ F:\D\IONIC\quicktask\quicktask-android\quicktask\platforms\android\src\org\apache\cordova\filetransfer\FileTransfer.java:851: error: cannot find symbol

                    FileUtils filePlugin = (FileUtils) pm.getPlugin("File");
                    ^   symbol: class FileUtils F:\D\IONIC\quicktask\quicktask-android\quicktask\platforms\android\src\org\apache\cordova\filetransfer\FileTransfer.java:851:

error: cannot find symbol FileUtils filePlugin = (FileUtils) pm.getPlugin("File"); ^ symbol: class FileUtils Note: Some input files use or override a deprecated API.

Note: Recompile with -Xlint:deprecation for details. Note: F:\D\IONIC\quicktask\quicktask-android\quicktask\platforms\android\src\org\apache\cordova\filetransfer\FileTransfer.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 3 errors :compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':compileDebugJavaWithJavac'.

    Compilation failed; see the compiler error output for details.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED

Total time: 48.087 secs

(node:6372) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output: Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. F:\D\IONIC\quicktask\quicktask-android\quicktask\platforms\android\src\org\apache\cordova\filetransfer\FileTransfer.java:49: error: package org.apache.cordova.file does not exist import org.apache.cordova.file.FileUtils; ^ F:\D\IONIC\quicktask\quicktask-android\quicktask\platforms\android\src\org\apache\cordova\filetransfer\FileTransfer.java:851: error: cannot find symbol FileUtils filePlugin = (FileUtils) pm.getPlugin("File"); ^ symbol: class FileUtils F:\D\IONIC\quicktask\quicktask-android\quicktask\platforms\android\src\org\apache\cordova\filetransfer\FileTransfer.java:851: error: cannot find symbol FileUtils filePlugin = (FileUtils) pm.getPlugin("File"); ^ symbol: class FileUtils Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: F:\D\IONIC\quicktask\quicktask-android\quicktask\platforms\android\src\org\apache\cordova\filetransfer\FileTransfer.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 3 errors

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':compileDebugJavaWithJavac'.

    Compilation failed; see the compiler error output for details.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

2
Note we prefer a technical style of writing here. We gently discourage greetings, hope-you-can-helps, thanks, advance thanks, notes of appreciation, regards, kind regards, signatures, please-can-you-helps, chatty material and abbreviated txtspk, pleading, how long you've been stuck, voting advice, meta commentary, etc. Just explain your problem, and show what you've tried, what you expected, and what actually happened.halfer
As you can see from the spurious Markdown formatting, quote blocks are not ideal ways to format exceptions/logs here. I would recommend code/block formatting instead to produce the most readable format.halfer

2 Answers

1
votes

I also encountered this problem, which is caused by the low version of cordova-android. If you are in ionic cordova platform add android, have noticed that cordova-plugin-file is required for cordova-android version greater than or equal to 6.3.0.

So just run the command:

ionic cordova platform remove android
ionic cordova platform add [email protected]

This will be packaged successfully after running the ionic build.

0
votes

It is because of some android support version. If you check your android project in some android studio IDE, you can see the version of android support, which is not compatible with the version used by that File plugin.

You can use the cordova-android-support-gradle-release plugin, it can help you set the correct version during building. You can google it about how to use it.