Ion error when creating Android when loading Gradle

I am very new to the Ionic framework :)

>npm install -g cordova >npm install -g ionic >ionic start test blank >cd test >ionic platform add android 

When I use ' >ionic build android ', start downloading gradle, but I cannot load and get an error message.

What caused this error and how to fix it ?!

I download Gradle and install it on the PC, but it wants to download again. Can I add Gradle to a project offline?

 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) 
+62
android build ionic-framework
Apr 26 '15 at 6:34
source share
16 answers

I am using Ionic version 1.7.14, and the Url distribution is found in the following file. myApp/platforms/android/cordova/lib/builders/GradleBuilder.js.

I needed to specify a locally loaded gradle, as indicated in this answer.

I had the same problem. I added gradle to my project offline.

After loading gradle from the highlighted link (here http://services.gradle.org/distributions/gradle-2.2.1-all.zip ) paste it somewhere in the format myApp\platforms\android\gradle\gradle-2.2.1-all.zip and in build.js from myApp\platforms\android\cordova\lib\build.js find this:

 var distributionUrl = 'distributionUrl=http\\://services.gradle.org/distributions/gradle-2.2.1-all.zip'; 

And replace it with your own file location:

 var distributionUrl = 'distributionUrl=../gradle-2.2.1-all.zip'; 
+103
May 03 '15 at 18:42
source share

Since the solution posted above should include .zip in a folder about 55 MB in size

You can also force the CLI to use Ant instead of gradle during build with the following command:

 cordova build android -- --ant 
+47
May 30 '15 at 18:05
source share

I ran into this problem because our network proxy blocks the download of the zip file. Here is what I found:

NOTE: this differs from the β€œaccepted” answer in that we do not modify the Cordoba library directly. This is much less error prone or may be overwritten when running ionic state restore

  • Download gradle - http://services.gradle.org/distributions/gradle-2.2.1-all.zip

  • Put this file in platforms/android/gradle . However, if you integrate this into your build process, you may want to use it somewhere less volatile and add a step to copy the file to this location.

  • Set the environment variable CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL to ../gradle-2.2.1-all.zip

    • linux / osx: add export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL="../gradle-2.2.1-all.zip" to your ~ / .bashrc file
    • windows: setx CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL ../gradle-2.2.1-all.zip
  • Launch ionic build android

+18
Jun 09 '16 at 17:25
source share

Another option from the command line is to run $ export JAVA_OPTS="-Dhttp.proxyHost=proxy-url.com -Dhttp.proxyPort=911 -Dhttps.proxyHost=secure-proxy-url.com -Dhttps.proxyPort=911" before the command assembly cordova.

+10
Nov 13 '15 at 15:04
source share

If you need to use a proxy server on your network, add the gradle.properties file to %USER_HOME%/.gradle below, but replace the values ​​with your proxy data. It worked for me.

 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 
+7
Dec 03 '15 at 15:00
source share

Cordoba 6.0.0 / Visual Studio Code 0.10.6

TL; DR

Manually download http://services.gradle.org/distributions/gradle-2.2.1-all.zip .

Put it in appName\platforms\android\gradle\

 set CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL=..\gradle-2.2.1-all.zip 

Run the code and compile.

Explanation:

GradleBuilder.js sets distributionUrl as follows:

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

Script works in appName\platforms\android\gradle\wrapper

Exit:

File Download: // appname / platform / android / gradle / gradle -2.2.1-all.zip

+7
04 Feb '16 at 0:40
source share

Hi everyone, I had the same problem.

In the platform \ 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 he worked.

+5
Jul 02 '15 at 6:11
source share

I had the same problem and it was resolved by removing the prefabricated tools 24 and installing the collectors 23 from the SDK Manager.

+3
09 Oct '16 at 15:46
source share

Alternatively, if you have a web server on your local host, download and place gradle (exactly the tested version, i.e. http://downloads.gradle.org/distributions/gradle-2.2.1-all.zip during this message) in the root directory of www and change the platform file \ android \ cordova \ lib \ build.js in your application directory to this:

  var distributionUrl = 'distributionUrl=http\\://localhost/gradle-2.2.1-all.zip'; 

Changing the URL of the local file (not the http address) will not work for me under windows, and it will complain that the URL has an unknown protocol.

+2
Jun 15 '15 at 3:19
source share

There seems to be a problem for 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 do not know why they all add "distributionUrl =" as follows (this does not work for me):

  var distributionUrl = 'distributionUrl=http\\://localhost/gradle-2.2.1-all.zip'; 

By the way, I use ionic 2.

Pay attention to the path if you do not want to use localhost . It will automatically add myApp/platforms/android/gradle/wrapper to the myApp/platforms/android/gradle/wrapper distribution, for example, if you put gradle -2.2.1-all.zip in the myApp/platforms/android/gradle , you need to install:

 var distributionUrl = '../gradle-2.2.1-all.zip'; 
+2
Apr 18 '16 at 7:59
source share

Recently, I have run into the same problem, and I searched here and there.

Finally, for the last build, I found a solution.

After the command "andic platform add android" go to the platforms /android/cordova/lib/builders/GradleBuilder.js

Search

 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 
+1
Feb 17 '16 at 8:48
source share

All the answers here all say the same thing when it can be done easier than the top answer. The Android SDK update should fix it, and you can do it using 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 reposition issue (this is essentially the same issue).

But after you do this, it will work.

0
Aug 24 '16 at 6:22
source share

It looks like Windows Defender or some other anti-virus system ruined your installation. Therefore, temporarily disable the firewall and run the command:

 ionic build android (or ios) 

At the end you will receive a BUILD SUCCESSFUL message ...

0
Sep 06 '16 at 14:29
source share

This is due to a Gradle error.

Download the file http://services.gradle.org/distributions/gradle-2.14.1-all.zip and extract it in any directory and set the path using open cmd and type: setx path (extracted directory) / bin

After that, re-run cmd and see if Gradle works by releasing gradle -v . It shows the release version of Gradle. Now bug fixed; run ionic build android .

0
Mar 23 '17 at 6:57
source share

Android platform update helped me:

  • Cordova Android Platform Platform Update
  • Cordoba is cooking
  • Cordoba compiles and finally
  • Cordoba will build
-one
Jan 20 '16 at 20:12
source share

Download JDK version 8 and uninstall all existing versions.

And update Ionic.

I hope your problem is resolved.

-one
Oct 27 '17 at 7:13
source share



All Articles