Ionic Cordova构建android无法正常工作
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ionic Cordova构建android无法正常工作相关的知识,希望对你有一定的参考价值。
我安装了离子和cordova。
当我检查我的构建并模拟ios工作正常但android无法正常工作。
我得到的信息是:
> cordova build android
Android Studio project detected
Running command: /Users/hongzhiyuan/Desktop/nihao_app/app/niHAO/hooks/after_prepare/010_add_platform_class.js /Users/hongzhiyuan/Desktop/nihao_app/app/niHAO
ANDROID_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 gradle
but。由于我位于中国,一些代码无法在没有vpn的情况下下载现在它正在运行
以上是关于Ionic Cordova构建android无法正常工作的主要内容,如果未能解决你的问题,请参考以下文章
安装cordova插件后我无法在ionic中构建android apk
无法在 Android 上构建和运行基于 ionic 和 cordova 的应用程序
Ionic 3 错误:“文件 google-services.json 丢失。没有它,Google 服务插件无法运行。”在 ionic cordova 构建/准备 android