添加ionic插件cordova-plugin-file可能会遇到如下报错
- 提示信息
:processDebugResources
:generateDebugSources
:compileDebugJava
apache/cordova/filetransfer/FileTransfer.java:59: error: package org.apache.cordova.file does not exist
import org.apache.cordova.file.FileUtils;
^
apache/cordova/filetransfer/FileTransfer.java:912: error: cannot find symbol
FileUtils filePlugin = (FileUtils) pm.getPlugin("File");
^
symbol: class FileUtils
cordova/filetransfer/FileTransfer.java:912: error: cannot find symbol
FileUtils filePlugin = (FileUtils) pm.getPlugin("File");
: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 --debugoption to get more log output.
BUILD FAILED
Total time: 6 mins 51.314 secs
如果你在ionic cordova platform add android时,有注意到cordova-plugin-file是需要cordova-android版本大于等于6.3.0
- 解决方案
所以只需要运行命令
ionic cordova platform remove android
ionic cordova platform add android@6.3.0
这样就在运行ionic build就能打包成功了
本文解决在使用Ionic框架结合Cordova平台添加文件插件时遇到的编译错误,详细介绍了错误信息及原因,并提供了解决方案,即更新cordova-android版本至6.3.0及以上。
5550

被折叠的 条评论
为什么被折叠?



