[英]ERROR: An error occurred while running subprocess cordova
I build an app on Ionic framework, it works on the browser but when I try to compile it on the emulator I have got this error:我在 Ionic 框架上构建了一个应用程序,它可以在浏览器上运行,但是当我尝试在模拟器上编译它时出现此错误:
Checking Java JDK and Android SDK versions ANDROID_SDK_ROOT=undefined (recommended setting) ANDROID_HOME=C:\Users\user\AppData\Local\Android\Sdk (DEPRECATED) Starting a Gradle Daemon (subsequent builds will be faster)检查 Java JDK 和 Android SDK 版本 ANDROID_SDK_ROOT=undefined (推荐设置) ANDROID_HOME=C:\Users\user\AppData\Local\Android\Sdk (DEPRECATED) 启动 Gradle Daemon (后续构建会更快)
FAILURE: Build failed with an exception. FAILURE:构建失败并出现异常。
Error occurred during initialization of VM Could not reserve enough space for 2097152KB object heap初始化 VM 时发生错误无法为 2097152KB 对象堆保留足够的空间
Try: Run with --stacktrace option to get the stack trace.尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。 Run with --info or --debug option to get more log output.
使用 --info 或 --debug 选项运行以获得更多日志输出。 Run with --scan to get full insights.
运行 --scan 以获得完整的见解。
Get more help at https://help.gradle.org C:\Gradle\gradle-5.3.1\bin\gradle: Command failed with exit code 1 [ERROR] An error occurred while running subprocess cordova.在https://help.gradle.org C:\Gradle\gradle-5.3.1\bin\gradle 获得更多帮助:命令失败,退出代码 1 [错误] 运行子进程 cordova 时出错。
cordova run android exited with exit code 1. Re-running this command with the --verbose flag may provide more information.
This is because the path to Android Sdk is not set correctly.这是因为未正确设置 Android Sdk 的路径。 Please check the correct path for Sdk, tools, platform-tools, emulator and Android build-tools.
请检查 Sdk、工具、平台工具、模拟器和 Android 构建工具的正确路径。
Please, realize that the configuration recommended for Ionic has changed a bit.
请注意,为 Ionic 推荐的配置已经发生了一些变化。 Now the notation recommended is as follows:
现在推荐的符号如下:
ANDROID_SDK_ROOT=/home/username/Android/Sdk (recommended setting)
ANDROID_HOME=/home/username/Android/Sdk (DEPRECATED)
In Linux or Mac OS X configure the path into the ~/.bashrc, ~/.bash_profile file:在 Linux 或 Mac OS X 中,将路径配置到 ~/.bashrc、~/.bash_profile 文件中:
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/build-tools
At the end, after save the configuration dont forget to do the command:最后,保存配置后不要忘记执行命令:
source ~/.bashrc
or as your case或作为你的情况
source ~/.bash_profile
For the Windows users check the global variables.对于 Windows 用户,请检查全局变量。
尝试运行npm cache clean
并重新安装cordova ...为我工作。
I finally found the solution from a related solved topic: The solution is:我终于从一个相关的已解决主题中找到了解决方案:解决方案是:
ionic platform rm android ionic platform add android@latest ionic resources ionic run android ionic platform rm android ionic platform add android@latest ionic 资源 ionic run android
ionic repair
worked for me. ionic repair
对我有用。 Just give it a try and see if that works for you.试一试,看看它是否适合你。 Good luck!
祝你好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.