Gradle 다운로드시 Ionic 빌드 Android 오류
저는 Ionic 프레임 워크를 처음 접했습니다. :)
>npm install -g cordova
>npm install -g ionic
>ionic start test blank
>cd test
>ionic platform add android
' >ionic build android
'start download gradle을 사용하지만 다운로드 할 수없고 오류가 발생합니다.
이 오류의 원인은 무엇이며 어떻게 해결할 수 있습니까?!
Gradle을 다운로드하여 PC에 설치했지만 다시 다운로드하고 싶습니다. 오프라인으로 프로젝트에 Gradle을 추가 할 수 있나요?
C:\Users\LENOVO2014\test>ionic build android
running cordova build android
Running command: "C:\Program Files\nodejs\node.exe" C:\Users\LENOVO2014\myApp\ho
oks\after_prepare\010_add_platform_class.js C:\Users\LENOVO2014\myApp
add to body class: platform-android
Running command: C:\Users\LENOVO2014\myApp\platforms\android\cordova\build.bat
ANDROID_HOME=D:\program\Programing\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_31
Running: C:\Users\LENOVO2014\myApp\platforms\android\gradlew cdvBuildDebug -b C:
\Users\LENOVO2014\myApp\platforms\android\build.gradle -Dorg.gradle.daemon=true
Downloading http://services.gradle.org/distributions/gradle-2.2.1-all.zip
................................................................................
................................................................................
................................................................................
............................................
Exception in thread "main" java.lang.RuntimeException: java.net.SocketException:
Connection reset
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
essManager.java:78)
at org.gradle.wrapper.Install.createDist(Install.java:47)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:189)
at java.net.SocketInputStream.read(SocketInputStream.java:121)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:284)
at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
at sun.net.www.MeteredStream.read(MeteredStream.java:134)
at java.io.FilterInputStream.read(FilterInputStream.java:133)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Http
URLConnection.java:3335)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Http
URLConnection.java:3328)
at org.gradle.wrapper.Download.downloadInternal(Download.java:63)
at org.gradle.wrapper.Download.download(Download.java:45)
at org.gradle.wrapper.Install$1.call(Install.java:60)
at org.gradle.wrapper.Install$1.call(Install.java:47)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
essManager.java:65)
... 3 more
C:\Users\LENOVO2014\myApp\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "C:\Users\LENOVO2014\myApp\platfo
rms\android\gradlew cdvBuildDebug -b C:\Users\LENOVO2014\myApp\platforms\android
\build.gradle -Dorg.gradle.daemon=true"
ERROR building one of the platforms: Error: C:\Users\LENOVO2014\myApp\platforms\
android\cordova\build.bat: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: C:\Users\LENOVO2014\myApp\platforms\android\cordova\build.bat: Command fa
iled with exit code 1
at ChildProcess.whenDone (C:\Users\LENOVO2014\AppData\Roaming\npm\node_modul
es\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
Ionic 버전 1.7.14와 다음 파일에있는 distributionUrl을 사용하고 있습니다. myApp/platforms/android/cordova/lib/builders/GradleBuilder.js.
이 답변에 지정된대로 로컬로 다운로드 한 gradle을 가리켜 야했습니다.
나는 같은 문제가 있었다. 오프라인으로 프로젝트에 gradle을 추가했습니다.
발행 된 링크 (여기는 http://services.gradle.org/distributions/gradle-2.2.1-all.zip ) 에서 gradle을 다운로드 한 후 원하는 곳에 붙여넣고 myApp\platforms\android\gradle\gradle-2.2.1-all.zip
build.js에서 다음을 myApp\platforms\android\cordova\lib\build.js
찾으십시오.
var distributionUrl = 'distributionUrl=http\\://services.gradle.org/distributions/gradle-2.2.1-all.zip';
자신의 파일 위치로 바꿉니다.
var distributionUrl = 'distributionUrl=../gradle-2.2.1-all.zip';
위에 게시 된 솔루션은 약 55MB의 폴더에 .zip을 포함해야하기 때문에
다음 명령을 사용하여 빌드 중에 CLI가 gradle 대신 Ant를 사용하도록 강제 할 수도 있습니다.
cordova build android -- --ant
네트워크 프록시가 zip 파일의 다운로드를 차단하기 때문에이 문제가 발생했습니다. 내가 찾은 내용은 다음과 같습니다.
참고 : 이것은 Cordova의 라이브러리를 직접 수정하지 않는다는 점에서 "수락 된"답변과 다릅니다. 이것은 "오류"가 발생하거나 실행할 때 덮어 쓰는 경향이 훨씬 적습니다.
ionic state restore
다운로드 Gradle을 - http://services.gradle.org/distributions/gradle-2.2.1-all.zip
이 파일을
platforms/android/gradle
. 그러나 이것을 빌드 프로세스에 통합하는 경우 불안정한 위치에 고정하고 해당 위치에 파일을 복사하는 단계를 추가 할 수 있습니다.환경 변수
CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL
를 다음으로 설정하십시오.../gradle-2.2.1-all.zip
- linux / osx :
export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL="../gradle-2.2.1-all.zip"
~ / .bashrc 파일에 추가 - 창 :
setx CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL ../gradle-2.2.1-all.zip
- linux / osx :
운영
ionic build android
명령 줄의 또 다른 옵션 $ export JAVA_OPTS="-Dhttp.proxyHost=proxy-url.com -Dhttp.proxyPort=911 -Dhttps.proxyHost=secure-proxy-url.com -Dhttps.proxyPort=911"
은 cordova build 명령 전에 실행 하는 것입니다.
Cordova 6.0.0 / Visual Studio Code 0.10.6
TL; DR
수동으로 http://services.gradle.org/distributions/gradle-2.2.1-all.zip
.
넣어주세요 appName\platforms\android\gradle\
set CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL=..\gradle-2.2.1-all.zip
코드를 시작하고 컴파일하십시오.
설명:
GradleBuilder.js는 distributionUrl
다음과 같이 설정 합니다.
var distributionUrl = process.env [ 'CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'http \ : //services.gradle.org/distributions/gradle-2.2.1-all.zip';
스크립트 실행 appName\platforms\android\gradle\wrapper
출력은 다음과 같습니다.
파일 다운로드 :: //appname/platforms/android/gradle/gradle-2.2.1-all.zip
네트워크에서 프록시를 사용해야하는 경우 아래에 gradle.properties
파일 을 추가 %USER_HOME%/.gradle
하고 값을 프록시 세부 정보로 바꿉니다. 이것은 나를 위해 일했습니다.
gradlePropertiesProp=gradlePropertiesValue
sysProp=shouldBeOverWrittenBySysProp
envProjectProp=shouldBeOverWrittenByEnvProp
systemProp.system=systemValue
systemProp.http.proxyHost=myproxy.com
systemProp.http.proxyPort=8080
systemProp.http.nonProxyHosts=\*.mydomain.com|localhost
systemProp.https.proxyHost=myproxy.com
systemProp.https.proxyPort=8080
systemProp.https.nonProxyHosts=\*.mydomain.com|localhost
안녕하세요 모두 동일한 문제가 있습니다.
In the platforms\android\cordova\lib\build.js file, I changed
var distributionUrl = 'distributionUrl=http\\://services.gradle.org/distributions/gradle-2.2.1-all.zip';
to
var distributionUrl = 'distributionUrl=http://services.gradle.org/distributions/gradle-2.2.1-all.zip';
and it worked.
Alternatively, if you have a web server on your localhost, download and put the gradle (exactly the tested version, i.e. http://downloads.gradle.org/distributions/gradle-2.2.1-all.zip at the time of this post) in the www root and change the platforms\android\cordova\lib\build.js file in your application directory to this one:
var distributionUrl = 'distributionUrl=http\\://localhost/gradle-2.2.1-all.zip';
Changing the URL to a local file (not an http address) would not work for me under windows and it would complain that the URL has an unknown protocol.
There seems to be a problem for the previous solutions. At least none of them worked for me, and I just changed it to:
var distributionUrl = 'http://localhost/gradle-2.2.1-all.zip';
Then it works. I don't know why they all add "distributionUrl=" as follows (this doesn't work for me):
var distributionUrl = 'distributionUrl=http\\://localhost/gradle-2.2.1-all.zip';
BTW, I am using ionic 2.
Pay attention to the path if you don't want to use localhost
. It will automatically add myApp/platforms/android/gradle/wrapper
before distributionUrl, for example if you put gradle-2.2.1-all.zip in the myApp/platforms/android/gradle
directory, then you need to set:
var distributionUrl = '../gradle-2.2.1-all.zip';
I had the same problem, and it was solved with uninstalling build-tools 24, and installing build-tools 23 from SDK Manager.
I have faced the same problem recently, and I searched here and there.
Finally for the latest build I found the solution.
After "ionic platform add android" command, go to platforms/android/cordova/lib/builders/GradleBuilder.js
Search for
http\\://services.gradle.org/distributions/gradle-2.2.1-all.zip
and change it to
http\\://downloads.gradle.org/distributions/gradle-2.2.1-all.zip
All answers here are all saying the same thing when this could be done easier than the top answer. Updating your Android SDK should fix it, and you can do it with this one line from the terminal:
android update sdk --no-ui --all --filter "extra-android-m2repository"
or
android update sdk --no-ui --filter extra
Also see this repos issue (it's the essentially same problem).
But after you do that rebuild, and it should work.
It sounds like Windows Defender or some other antivirus system is messing up with your install. So temporarily deactivate your firewall and re-run the command:
ionic build android (or ios)
At the end you have the message BUILD SUCCESSFUL...
As far as ionic development concern,you will have to modified the distributionURL in GradleBuilder.js with below mentioned URL.
/android/cordova/lib/builders/GradleBuilder.js
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https://services.gradle.org/distributions/gradle-2.14.1-all.zip';
Updating the Android platform did the trick for me:
- Cordova platform update Android
- Cordova prepare,
- Cordova compile and finally
- Cordova build
This is because of a Gradle error.
Download the file http://services.gradle.org/distributions/gradle-2.14.1-all.zip and extract it in any of directory and set the path by open cmd and enter: setx path (extracted directory)/bin
After that, reopen cmd and check whether Gradle is works or not by issuing gradle -v
. It shows the Gradle version output. Now the error is fixed; run ionic build android
.
Download JDK version 8 and remove all existing versions.
And update Ionic.
I hope your problem will be solved.
참고URL : https://stackoverflow.com/questions/29874564/ionic-build-android-error-when-downloading-gradle
'programing tip' 카테고리의 다른 글
Pandas 데이터 프레임에서 모두 0이있는 행 삭제 (0) | 2020.10.28 |
---|---|
Laravel : 속성 별 컬렉션에서 객체 가져 오기 (0) | 2020.10.28 |
단위 테스트를 병렬이 아닌 직렬로 실행 (0) | 2020.10.28 |
jQuery를 사용하여 선택한 확인란의 값을 가져옵니다. (0) | 2020.10.28 |
CoreData에 어레이를 저장하는 방법은 무엇입니까? (0) | 2020.10.28 |