IT story

ionic 2-Error Android Studio에서 설치된 Gradle 버전을 찾을 수 없습니다

hot-time 2020. 7. 19. 09:17
반응형

ionic 2-Error Android Studio에서 설치된 Gradle 버전을 찾을 수 없습니다


나는 ionic 2 프로젝트를 만들고 다음과 같이 진단 코르도바 플러그인을 추가합니다 :

ionic plugin add cordova.plugins.diagnostic

npm install --save @ionic-native/diagnostic

다음과 같이 안드로이드 플랫폼을 추가하십시오 :

ionic platform add android@latest

그러나 ionic build android콘솔로 빌드 할 때이 오류가 발생합니다.

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

그리고 수동 gradle.3.3-all.zip을 다운로드하여 platform / android / cordova / lib / builders / GradleBuilder.js 에서이 distributionUrl var를 변경하려고합니다

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

에:

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

작동하지 않고 콘솔에서 마지막 오류가 발생합니다.

android @ latest 버전에 gradle을 추가하는 방법을 모르겠습니다


gradle을 설치하고 경로에 포함하십시오. 매뉴얼을 보려면 아래 링크를 클릭하십시오. https://gradle.org/install


인생은 길 등을 어지럽히는 데 너무 짧습니다.

내가 가진 이후 브루은 아이맥에 설치 , 난 그냥이 명령을 실행 :

brew install gradle

Ionic3 프로젝트가 성공적으로 구축되기 시작했습니다.


Android Studio가 설치되어 있어도 Linux에 gradle을 설치하면됩니다.

sudo apt 설치 gradle


Windows 사용자의 경우 :

답변 Gradle Download 의 링크에서 gradle 바이너리를 다운로드하십시오.

압축 파일을 'C : \ Gradle'또는 다른 곳으로 추출하십시오.

시작 메뉴> 검색에서 환경 변수 편집 대화 상자를여십시오.

시스템 변수에서 '새로 만들기'를 클릭 하고 아래와 같이 추가하십시오

변수 이름 GRADLE_HOME변수 값C:\Gradle\gradle-4.0.1

그런 다음 PATH시스템 변수 목록에서 변수를 선택 하십시오

이와 같이 변수 값에 gradle 경로를 추가하십시오. C:\Gradle\gradle-4.0.1\bin

그런 다음 win Key + R type cmd를 누른 다음 명령 터미널 유형 gradle -v에 >를 입력하십시오.

설정이 올 바르면 gradle 설치 세부 정보가 표시됩니다


cordova 버전 6.4.0 및 android 6.2.1에 문제가 있으므로 호환되는 버전 아래에서 시도하십시오.

코르도바 버전은 6.4.0이어야합니다.

sudo npm install -g cordova@6.4.0

프로젝트에 안드로이드 설치

sudo cordova platform 추가 android@6.1.2

 or

sudo 이온 플랫폼 android@6.1.2 추가


우분투에서 최신 버전을 설치 gradle하면 문제가 해결되었습니다.

최신 버전을 설치하려면 다음 단계를 수행하십시오.

sudo add-apt-repository ppa:cwchien/gradle

sudo apt-get update

sudo apt-get install gradle

다음을 사용하여 빌드하십시오.

cordova build android 또는 ionic cordova build android

참고 : 우분투 저장소에서 gradle을 설치하면 이전 버전 1.4가 설치되고 도움 sudo apt-get install gradle이되지 않으므로 ppa:cwchien/gradle이전 에 저장소를 추가하지 않은 경우 대부분의 경우 혼자 도움이되지 않습니다.


이미 Android Studio를 설치했으며 MacOSX Mojave의 ~ / .bash_profile에 gradle PATH를 추가하면됩니다. 또한 gradle이 업그레이드되면 경로를 다시 업데이트해야 할 수도 있습니다.

.bash_profile 예 :

export ANDROID_SDK_ROOT="~/Library/Android/sdk"
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export JAVA_HOME=$(/usr/libexec/java_home)
export GRADLE_PATH="~/.gradle/wrapper/dists/gradle-4.10.1-all/455itskqi2qtf0v2sja68alqd/gradle-4.10.1/bin"
export ANDROID_STUDIO="/Applications/Android Studio.app/Contents/MacOS"
export PATH="$PATH:$GRADLE_PATH:$ANDROID_STUDIO"

When edited your .bash_profile then run a command below to read it again.

source ~/.bash_profile

On Ubuntu 18.04, I intalled gradle with:

sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update
sudo apt-get install gradle

And Ready.


If you dont want to install gradle explicitly just to address this issue, you can overcome this by following the workaround as mentioned below:

  1. Look for check_reqs.js file under platforms\android\cordova\lib folder
  2. Edit the else part of androidStudioPath variable null check in get_gradle_wrapper function as below:

Existing code:

else { //OK, let's try to check for Gradle! return forgivingWhichSync('gradle'); }

Modified code:

else { //OK, let's try to check for Gradle! var sdkDir = process.env['ANDROID_HOME']; return path.join(sdkDir, 'tools', 'templates', 'gradle', 'wrapper', 'gradlew'); }

NOTE: This change needs to be done everytime when the android platform is removed and re-added

UPDATE: The above workaround will work fine till Cordova Android version 6.3.0. For Cordova Android 6.4.0 and above, Gradle needs to be installed as a standalone dependency. Please find Cordova Android 6.4.0 release notes for more info on this.


For Windows you can try below solution

Copy your gradle-->bin path and add it to system environment variable path.

In my case gradle path is

C:\Users\username\.gradle\wrapper\dists\gradle-3.3-all\55gk2rcmfc6p2dg9u9ohc3hw9\gradle-3.3\bin

This solution worked for me.


I solve this problem

Download gradle.zip from this site https://gradle.org/install. And follow the instructions indicated in the site.

Then open another terminal cmd and execute the command:

Cordova build android --prod --release
End

First of all uninstall ionic and cordova, later set your variables envarionment JAVA_HOME, ANDROID_HOME and PATH then reinstall ionic cordova and add platform like follow:

$ sudo npm install -g ionic cordova

$ ionic platform add android

The ionic will setup gradle packages properly.


In Arch Linux/Manjaro: sudo pacman -S gradle


I am on Microsoft Windows:

I encountered this error after upgrading Android Studio from 2.3.3 to 3.0. I solved it by changing the path to gradle in the PATH environment variable, which is now "gradle-4.1" for Android Studio 3.0 (previously it was "gradle-3.2" for Android Studio 2.3.3)


For Windows users:

Set-ExecutionPolicy RemoteSigned -scope CurrentUser
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
scoop install gradle

Just install the Gradle through the command line If you are using Mac try

brew install gradle

just install android studio and select your sdk folder as a android studio's sdk default folder and then android studio repair all the damage area and download needed files.


Download the latest gradle from https://gradle.org/install and set the gradle path upto bin in your PATH variable and export path in the directory you are working in

example : export PATH=/home/abc/android-sdk-linux/tools:/home/abc/android-sdk-linux/platform-tools:/home/abc/android-sdk-linux/tools:/home/abc/android-sdk-linux/platform-tools:/home/abc/Downloads/gradle-4.4.1/bin

I spent my whole day resolve this and ultimately this solution worked for me,


this worked with me on linux

sdk install gradle 4.9

install sdk from here https://sdkman.io/


I moved Android folder path to another path and taked this error.

I resolved to this problem in below.

I was changed to Gradle path in system variables. But not path in user variables. You must change to path in system variables

Screenshot this

Alternative Screenshot this


You will also get this error if you are on Windows and your project path has parenthesis in it. eg. "cordova(something)".

(At least until this issue is fixed.)


@Ghandi: Could someone let me know why this answer is downvoted? Yeah, why? It has finally solved this problem ...

In my mind there is a bug when gradle or sdk or android studio is installed in a different directory then the standard one. I have S:\android\Android Studio and S:\android\sdk.

The solution by Ghandi installed gradle somewhere one more time, but I was really exasperated for this: one or two "gradle" more doesn't hurt me anymore

참고URL : https://stackoverflow.com/questions/43480076/ionic-2-error-could-not-find-an-installed-version-of-gradle-either-in-android

반응형