添加ionic插件cordova-plugin-file可能會遇到以下報錯java
: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.0android
因此只須要運行命令
ionic cordova platform remove android
ionic cordova platform add android@6.3.0
這樣就在運行ionic build就能打包成功了apache