Ionic Cordova构建android无法正常工作

最是人间留不住,朱颜辞镜花辞树。这篇文章主要讲述Ionic Cordova构建android无法正常工作相关的知识,希望能为你提供帮助。
【Ionic Cordova构建android无法正常工作】我安装了离子和cordova。
当我检查我的构建并模拟ios工作正常但android无法正常工作。
我得到的信息是:

> cordova build android Android Studio project detectedRunning command: /Users/hongzhiyuan/Desktop/nihao_app/app/niHAO/hooks/after_prepare/010_add_platform_class.js /Users/hongzhiyuan/Desktop/nihao_app/app/niHAOANDROID_HOME=/Users/hongzhiyuan/Library/Android/sdk java_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home studio (node:28943) UnhandledPromiseRejectionWarning: CordovaError: Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper. Please include gradle in your path, or install Android Studio at Object.module.exports.check_gradle (/Users/hongzhiyuan/Desktop/nihao_app/app/niHAO/platforms/android/cordova/lib/check_reqs.js:150:18) at StudioBuilder.prepEnv (/Users/hongzhiyuan/Desktop/nihao_app/app/niHAO/platforms/android/cordova/lib/builders/StudioBuilder.js:216:23) at Api.module.exports.run (/Users/hongzhiyuan/Desktop/nihao_app/app/niHAO/platforms/android/cordova/lib/build.js:154:20) at /Users/hongzhiyuan/Desktop/nihao_app/app/niHAO/platforms/android/cordova/Api.js:342:43 at _fulfilled (/Users/hongzhiyuan/Desktop/nihao_app/app/niHAO/platforms/android/cordova/node_modules/q/q.js:854:54) at self.promiseDispatch.done (/Users/hongzhiyuan/Desktop/nihao_app/app/niHAO/platforms/android/cordova/node_modules/q/q.js:883:30) at Promise.promise.promiseDispatch (/Users/hongzhiyuan/Desktop/nihao_app/app/niHAO/platforms/android/cordova/node_modules/q/q.js:816:13) at /Users/hongzhiyuan/Desktop/nihao_app/app/niHAO/platforms/android/cordova/node_modules/q/q.js:624:44 at runSingle (/Users/hongzhiyuan/Desktop/nihao_app/app/niHAO/platforms/android/cordova/node_modules/q/q.js:137:13) at flush (/Users/hongzhiyuan/Desktop/nihao_app/app/niHAO/platforms/android/cordova/node_modules/q/q.js:125:13) (node:28943) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:28943) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

rm android平台并重新安装它但仍然遇到了同样的问题。知道如何让它有效吗?
答案
you can follow this steps:--Open Terminal.app. Create a new directory sudo mkdir /usr/local/gradle. Extract the downloaded Gradle distribution archive by executing sudo unzip gradle-4.0.2-all.zip -d /usr/local/gradle. Edit .bash_profile in your home directory to add GRADLE_HOME variable with the following line export GRADLE_HOME=/usr/local/gradle/gradle-4.0.2 Also update the PATH variable to include $GRADLE_HOME/bin. If you don’t already have the PATH variable add the following line export PATH=$GRADLE_HOME/bin:$PATH Run source ~/.bash_profile to executes the update version of .bash_profile. Or you can open a new Terminal.app to make this changes active.

或者点击此链接https://kodejava.org/how-do-i-install-gradle-in-os-x/
另一答案我发现了这个问题。这次我打开了我的vpn,再次做了brew install gradlebut。由于我位于中国,一些代码无法在没有vpn的情况下下载现在它正在运行

    推荐阅读