macOS Catalina下Ionic 3 Android打包报错settings.gradle不存在求助
我已经被这个问题折腾整整一周了,实在走投无路了,恳请各位大佬帮忙!在macOS Catalina系统上,我尝试执行ionic cordova build android --prod构建Ionic 3的Android应用,每次都失败——明明settings.gradle文件确实存在,但构建日志却一直提示找不到这个文件,我快疯了!
执行的构建命令
ionic cordova build android --prod
完整构建日志
ionic-app-scripts build --prod --target cordova --platform android
[21:20:07] ionic-app-scripts 3.2.2
[21:20:07] build prod started ...
[21:20:07] clean started ...
[21:20:07] clean finished in 4 ms
[21:20:07] copy started ...
[21:20:08] deeplinks started ...
[21:20:08] deeplinks finished in 19 ms
[21:20:08] ngc started ...
[21:20:21] ngc finished in 13.22 s
[21:20:21] preprocess started ...
[21:20:21] preprocess finished in 2 ms
[21:20:21] webpack started ...
[21:20:21] copy finished in 13.88 s
[21:20:46] webpack finished in 25.14 s
[21:20:46] uglify started ...
[21:20:46] sass started ...
[21:20:49] sass finished in 3.18 s
[21:20:49] cleancss started ...
[21:20:53] cleancss finished in 3.67 s
[21:21:04] uglify finished in 18.51 s
[21:21:04] postprocess started ...
[21:21:04] postprocess finished in 22 ms
[21:21:04] lint started ...
[21:21:04] build prod finished in 57.03 s
[21:21:12] lint finished in 7.06 s
cordova build android
ANDROID_HOME=/Users/bruno/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home
FAILURE: Build failed with an exception.
- What went wrong:
Could not read settings file '/Users/bruno/Desktop/TMT/Final/tutorial/platforms/android/settings.gradle' as it does not exist. // 我确认该文件实际存在 - Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights. - Get more help at https://help.gradle.org
BUILD FAILED in 3s
Error: /Users/bruno/.sdkman/candidates/gradle/5.6.3/bin/gradle: Command failed with exit code 1
Error output:
FAILURE: Build failed with an exception. - What went wrong:
Could not read settings file '/Users/bruno/Desktop/TMT/Final/tutorial/platforms/android/settings.gradle' as it does not exist. // 我确认该文件实际存在 - Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights. - Get more help at https://help.gradle.org
BUILD FAILED in 3s
[ERROR] An error occurred while running subprocess cordova.
我的环境信息
执行ionic info输出如下:
Ionic: Ionic CLI : 5.4.4 (/usr/local/lib/node_modules/ionic) Ionic Framework : ionic-angular 3.9.5 @ionic/app-scripts : 3.2.2 Cordova: Cordova CLI : 7.1.0 Cordova Platforms : android 6.3.0 Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.2, (及其他4个插件) Utility: cordova-res : 0.8.0 native-run : 未安装 System: Android SDK Tools : 26.1.1 (/Users/bruno/Library/Android/sdk) NodeJS : v10.16.3 (/usr/local/bin/node) npm : 6.9.0 OS : macOS Catalina
已经尝试过的解决方法
- 把Cordova CLI升级到了8版本
- 移除并重新添加了Android@6.3.0平台
- 移除并重新添加了Android@6.4.0平台
但以上操作都没用,还是出现同样的错误。如果有人能帮我找到解决方案,我真的万分感激!
内容的提问来源于stack exchange,提问作者Med Karim Garali

