Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

cordova - ionic 2 - Error Could not find an installed version of Gradle either in Android Studio

I create ionic 2 project and add diagnostic cordova plugin like this :

ionic plugin add cordova.plugins.diagnostic

npm install --save @ionic-native/diagnostic

and add android platform like this :

ionic platform add android@latest

but when build with ionic build android console give me this error :

Error: 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

and I try to download manualy gradle.3.3-all.zip and change this distributionUrl var in platform/android/cordova/lib/builders/GradleBuilder.js

 var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\://services.gradle.org/distributions/gradle-3.3-all.zip'

to:

var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'file:///E:/gradles/gradle-3.3-all.zip';

but not working and console give me last error.

I dont know how to add gradle for android@latest version

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Life is too short to spend it on messing with paths, etc.

Since I had Homebrew installed on the iMac, I just ran this command:

brew install gradle

The Ionic3 project started to build successfully.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...