Ionic在下载Gradle时构建Android错误

时间:2021-03-19 20:24:08

I'm 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 download gradle, but I can't download and get an error.

当我使用>ionic build android时,我开始下载gradle,但是我无法下载并得到错误。

What caused this error and how can I fix it?!

是什么导致了这个错误?

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

我下载了Gradle并将其安装在电脑上,但是它想要再次下载。我可以在离线项目中添加Gradle吗?

C:\Users\LENOVO2014\test>ionic build androidrunning cordova build androidRunning command: "C:\Program Files\nodejs\node.exe" C:\Users\LENOVO2014\myApp\hooks\after_prepare\010_add_platform_class.js C:\Users\LENOVO2014\myAppadd to body class: platform-androidRunning command: C:\Users\LENOVO2014\myApp\platforms\android\cordova\build.batANDROID_HOME=D:\program\Programing\Android\sdkJAVA_HOME=C:\Program Files\Java\jdk1.8.0_31Running: C:\Users\LENOVO2014\myApp\platforms\android\gradlew cdvBuildDebug -b C:\Users\LENOVO2014\myApp\platforms\android\build.gradle -Dorg.gradle.daemon=trueDownloading 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(ExclusiveFileAccessManager.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(HttpURLConnection.java:3335)        at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.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(ExclusiveFileAccessManager.java:65)        ... 3 moreC:\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\platforms\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 1You may not have the required environment or OS to build this projectError: C:\Users\LENOVO2014\myApp\platforms\android\cordova\build.bat: Command failed with exit code 1    at ChildProcess.whenDone (C:\Users\LENOVO2014\AppData\Roaming\npm\node_modules\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)

17 个解决方案

#1


107  

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

我正在使用以下文件中的Ionic版本1.7.14和distributionUrl。科尔多瓦myApp /平台/ android / / lib /建筑商/ GradleBuilder.js。

I had to point the locally downloaded gradle as specified in this answer.

我必须按此答案中指定的本地下载等级。

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

我遇到了同样的问题。我把gradle添加到我的离线项目中。

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

从已发布的链接下载gradle(这里是http://services.gradle.org/distributions/gradle 2.2.1-all.zip)后,将它粘贴到myApp\platform \android\ \ \ \gradle\ \ \ \ \ \ 2.2.1-all上。zip和构建。js的科尔多瓦myApp \ android平台\ \ \ lib \构建。js找到:

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

And replace it with your own file's location:

并将其替换为您自己的文件的位置:

var distributionUrl = 'distributionUrl=../gradle-2.2.1-all.zip';

#2


50  

Since the solution posted above needs to include .zip into folder that is about 55MB

由于上面发布的解决方案需要包含.zip到大约55MB的文件夹中

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

您还可以通过以下命令强制CLI在构建期间使用Ant而不是gradle:

cordova build android -- --ant

#3


19  

I ran into this issue as our network proxy is blocking the download of the zip file. Here's what I found:

我遇到了这个问题,因为我们的网络代理正在阻止zip文件的下载。以下是我的发现:

NOTE: this differs from the "accepted" answer in that we aren't modifying Cordova's library directly. This is far less prone to "error" or being overwritten when you run ionic state restore

注:这与“公认”的答案不同,我们没有直接修改Cordova的库。在运行离子状态恢复时,这远不容易发生“错误”或被覆盖

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

    下载gradle - http://services.gradle.org/distributions/gradle-2.2.1-all.zip

  2. Put this file in platforms/android/gradle. However, if you're integrating this into your build process, you may want to stick it somewhere less volatile and add a step to copy the file into that location.

    把这个文件放到平台/android/gradle上。但是,如果要将其集成到构建过程中,您可能希望将其粘贴到不那么易变的位置,并添加一个步骤将文件复制到该位置。

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

    将环境变量CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL设置为../gradle .2.1-all.zip

    • linux/osx: add export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL="../gradle-2.2.1-all.zip" to your ~/.bashrc file
    • linux / osx:添加CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL = " . . / gradle-2.2.1-all出口。~ / zip”。bashrc文件(
    • windows: setx CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL ../gradle-2.2.1-all.zip
    • windows:对于setx CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL . . / gradle-2.2.1-all.zip
  4. Run ionic build android

    运行离子构建android

#4


11  

Another option from 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 cordova build command.

命令行中的另一个选项是运行$ export JAVA_OPTS="-Dhttp. proxyhost =proxy-url.com -Dhttp。proxyPort -Dhttps = 911 -Dhttps.proxyHost = secure-proxy-url.com。在cordova建立命令之前。

#5


8  

If you require to use a proxy on your network then add a gradle.properties file in %USER_HOME%/.gradle with the below but replacing the values with your proxy details. This worked for me.

如果您需要在您的网络上使用代理,那么添加一个等级。在% USER_HOME % /属性文件。渐变为如下所示,但是用代理细节替换值。这为我工作。

gradlePropertiesProp=gradlePropertiesValuesysProp=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

#6


8  

Cordova 6.0.0 / Visual Studio Code 0.10.6

Cordova 6.0.0 / Visual Studio代码0.10.6

TL;DR

博士TL;

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

手动下载http://services.gradle.org/distributions/gradle-2.2.1-all.zip。

Place it in appName\platforms\android\gradle\

把它放在浏览器名称\ android \ gradle \ \平台

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

Start code and compile.

开始代码和编译。

Explanation:

解释:

GradleBuilder.js sets distributionUrl as follows:

GradleBuilder。js设置distributionUrl如下:

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

var distributionUrl =过程。env(“CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL”)| |“http \:/ /services.gradle.org/distributions/gradle-2.2.1-all.zip';

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

脚本运行在android浏览器名称\平台\ \ gradle \包装

Output is:

输出是:

Downloading file://appname/platforms/android/gradle/gradle-2.2.1-all.zip

下载文件:/ /浏览器名称/平台/ android / gradle / gradle-2.2.1-all.zip

#7


6  

Hi all I had the same issue.

嗨,我都有同样的问题。

In the platforms\android\cordova\lib\build.js file, I changed

科尔多瓦在android平台\ \ \ lib \构建。js文件,我改变了

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.

它工作。

#8


5  

I had the same problem, and it was solved with uninstalling build-tools 24, and installing build-tools 23 from SDK Manager.

我遇到了同样的问题,通过卸载构建工具24和从SDK管理器安装构建工具23解决了这个问题。

#9


3  

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:

或者,如果您的本地主机上有一个web服务器,请下载并将gradle(即测试版本,即http://downloads.gradle.org/distributions/gradle 2.2.1-all.zip)放在www的根目录中,并更改基于android\cordova\lib的搭建。在您的应用程序目录中的js文件:

 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.

在windows下,将URL更改为本地文件(而不是http地址)对我来说行不通,它会抱怨URL有一个未知的协议。

#10


3  

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

它的工作原理。我不知道为什么他们都添加了“distributionUrl=”如下(这对我不适用):

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

BTW, I am using ionic 2.

顺便说一下,我用的是离子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:

如果不想使用localhost,请注意路径。它会自动添加myApp/平台/android/gradle/包装器,然后再分配url,例如,如果你把gradle-2.2.1-all。在myApp/platform /android/gradle目录中进行压缩,需要设置:

var distributionUrl = '../gradle-2.2.1-all.zip';

#11


2  

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

“ionic platform add android”命令后,进入platform /android/cordova/lib/builders/ gradlebuild .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

#12


0  

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 SDK需要修复,你可以用终端的这一行来完成:

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).

还可以看到这个repos问题(本质上是同一个问题)。

But after you do that rebuild, and it should work.

但是在你重建之后,它就会起作用。

#13


0  

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:

这听起来像是Windows卫士或者其他防病毒系统把你的安装搞砸了。因此暂时停用防火墙并重新运行命令:

ionic build android (or ios)

At the end you have the message BUILD SUCCESSFUL...

最后,你的信息构建成功了……

#14


0  

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

下载该文件http://services.gradle.org/distributions/gradle-2.14.1-all.zip并将其解压到任何目录中,并通过打开cmd并输入:setx路径(提取的目录)/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.

在此之后,重新打开cmd并通过发布level -v检查Gradle是否正常。它显示了渐变版本输出。误差是固定的;运行离子构建android。

#15


0  

As far as ionic development concern,you will have to modified the distributionURL in GradleBuilder.js with below mentioned URL.

至于ionic开发,您将不得不在GradleBuilder中修改distributionURL。以下所提到的URL。

/android/cordova/lib/builders/GradleBuilder.js

科尔多瓦/ android / / lib /建筑商/ GradleBuilder.js

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

var distributionUrl =过程。env(“CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL”)| |“https://services.gradle.org/distributions/gradle-2.14.1-all.zip”;

#16


-1  

Updating the Android platform did the trick for me:

更新Android平台对我来说很有用:

  • Cordova platform update Android
  • 科尔多瓦Android平台更新
  • Cordova prepare,
  • 科尔多瓦准备,
  • Cordova compile and finally
  • 科尔多瓦编译和最后
  • Cordova build
  • 科尔多瓦构建

#17


-1  

Download JDK version 8 and remove all existing versions.

下载JDK 8并删除所有现有版本。

And update Ionic.

和更新离子。

I hope your problem will be solved.

我希望你的问题能得到解决。

#1


107  

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

我正在使用以下文件中的Ionic版本1.7.14和distributionUrl。科尔多瓦myApp /平台/ android / / lib /建筑商/ GradleBuilder.js。

I had to point the locally downloaded gradle as specified in this answer.

我必须按此答案中指定的本地下载等级。

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

我遇到了同样的问题。我把gradle添加到我的离线项目中。

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

从已发布的链接下载gradle(这里是http://services.gradle.org/distributions/gradle 2.2.1-all.zip)后,将它粘贴到myApp\platform \android\ \ \ \gradle\ \ \ \ \ \ 2.2.1-all上。zip和构建。js的科尔多瓦myApp \ android平台\ \ \ lib \构建。js找到:

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

And replace it with your own file's location:

并将其替换为您自己的文件的位置:

var distributionUrl = 'distributionUrl=../gradle-2.2.1-all.zip';

#2


50  

Since the solution posted above needs to include .zip into folder that is about 55MB

由于上面发布的解决方案需要包含.zip到大约55MB的文件夹中

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

您还可以通过以下命令强制CLI在构建期间使用Ant而不是gradle:

cordova build android -- --ant

#3


19  

I ran into this issue as our network proxy is blocking the download of the zip file. Here's what I found:

我遇到了这个问题,因为我们的网络代理正在阻止zip文件的下载。以下是我的发现:

NOTE: this differs from the "accepted" answer in that we aren't modifying Cordova's library directly. This is far less prone to "error" or being overwritten when you run ionic state restore

注:这与“公认”的答案不同,我们没有直接修改Cordova的库。在运行离子状态恢复时,这远不容易发生“错误”或被覆盖

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

    下载gradle - http://services.gradle.org/distributions/gradle-2.2.1-all.zip

  2. Put this file in platforms/android/gradle. However, if you're integrating this into your build process, you may want to stick it somewhere less volatile and add a step to copy the file into that location.

    把这个文件放到平台/android/gradle上。但是,如果要将其集成到构建过程中,您可能希望将其粘贴到不那么易变的位置,并添加一个步骤将文件复制到该位置。

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

    将环境变量CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL设置为../gradle .2.1-all.zip

    • linux/osx: add export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL="../gradle-2.2.1-all.zip" to your ~/.bashrc file
    • linux / osx:添加CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL = " . . / gradle-2.2.1-all出口。~ / zip”。bashrc文件(
    • windows: setx CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL ../gradle-2.2.1-all.zip
    • windows:对于setx CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL . . / gradle-2.2.1-all.zip
  4. Run ionic build android

    运行离子构建android

#4


11  

Another option from 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 cordova build command.

命令行中的另一个选项是运行$ export JAVA_OPTS="-Dhttp. proxyhost =proxy-url.com -Dhttp。proxyPort -Dhttps = 911 -Dhttps.proxyHost = secure-proxy-url.com。在cordova建立命令之前。

#5


8  

If you require to use a proxy on your network then add a gradle.properties file in %USER_HOME%/.gradle with the below but replacing the values with your proxy details. This worked for me.

如果您需要在您的网络上使用代理,那么添加一个等级。在% USER_HOME % /属性文件。渐变为如下所示,但是用代理细节替换值。这为我工作。

gradlePropertiesProp=gradlePropertiesValuesysProp=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

#6


8  

Cordova 6.0.0 / Visual Studio Code 0.10.6

Cordova 6.0.0 / Visual Studio代码0.10.6

TL;DR

博士TL;

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

手动下载http://services.gradle.org/distributions/gradle-2.2.1-all.zip。

Place it in appName\platforms\android\gradle\

把它放在浏览器名称\ android \ gradle \ \平台

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

Start code and compile.

开始代码和编译。

Explanation:

解释:

GradleBuilder.js sets distributionUrl as follows:

GradleBuilder。js设置distributionUrl如下:

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

var distributionUrl =过程。env(“CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL”)| |“http \:/ /services.gradle.org/distributions/gradle-2.2.1-all.zip';

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

脚本运行在android浏览器名称\平台\ \ gradle \包装

Output is:

输出是:

Downloading file://appname/platforms/android/gradle/gradle-2.2.1-all.zip

下载文件:/ /浏览器名称/平台/ android / gradle / gradle-2.2.1-all.zip

#7


6  

Hi all I had the same issue.

嗨,我都有同样的问题。

In the platforms\android\cordova\lib\build.js file, I changed

科尔多瓦在android平台\ \ \ lib \构建。js文件,我改变了

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.

它工作。

#8


5  

I had the same problem, and it was solved with uninstalling build-tools 24, and installing build-tools 23 from SDK Manager.

我遇到了同样的问题,通过卸载构建工具24和从SDK管理器安装构建工具23解决了这个问题。

#9


3  

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:

或者,如果您的本地主机上有一个web服务器,请下载并将gradle(即测试版本,即http://downloads.gradle.org/distributions/gradle 2.2.1-all.zip)放在www的根目录中,并更改基于android\cordova\lib的搭建。在您的应用程序目录中的js文件:

 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.

在windows下,将URL更改为本地文件(而不是http地址)对我来说行不通,它会抱怨URL有一个未知的协议。

#10


3  

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

它的工作原理。我不知道为什么他们都添加了“distributionUrl=”如下(这对我不适用):

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

BTW, I am using ionic 2.

顺便说一下,我用的是离子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:

如果不想使用localhost,请注意路径。它会自动添加myApp/平台/android/gradle/包装器,然后再分配url,例如,如果你把gradle-2.2.1-all。在myApp/platform /android/gradle目录中进行压缩,需要设置:

var distributionUrl = '../gradle-2.2.1-all.zip';

#11


2  

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

“ionic platform add android”命令后,进入platform /android/cordova/lib/builders/ gradlebuild .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

#12


0  

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 SDK需要修复,你可以用终端的这一行来完成:

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).

还可以看到这个repos问题(本质上是同一个问题)。

But after you do that rebuild, and it should work.

但是在你重建之后,它就会起作用。

#13


0  

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:

这听起来像是Windows卫士或者其他防病毒系统把你的安装搞砸了。因此暂时停用防火墙并重新运行命令:

ionic build android (or ios)

At the end you have the message BUILD SUCCESSFUL...

最后,你的信息构建成功了……

#14


0  

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

下载该文件http://services.gradle.org/distributions/gradle-2.14.1-all.zip并将其解压到任何目录中,并通过打开cmd并输入:setx路径(提取的目录)/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.

在此之后,重新打开cmd并通过发布level -v检查Gradle是否正常。它显示了渐变版本输出。误差是固定的;运行离子构建android。

#15


0  

As far as ionic development concern,you will have to modified the distributionURL in GradleBuilder.js with below mentioned URL.

至于ionic开发,您将不得不在GradleBuilder中修改distributionURL。以下所提到的URL。

/android/cordova/lib/builders/GradleBuilder.js

科尔多瓦/ android / / lib /建筑商/ GradleBuilder.js

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

var distributionUrl =过程。env(“CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL”)| |“https://services.gradle.org/distributions/gradle-2.14.1-all.zip”;

#16


-1  

Updating the Android platform did the trick for me:

更新Android平台对我来说很有用:

  • Cordova platform update Android
  • 科尔多瓦Android平台更新
  • Cordova prepare,
  • 科尔多瓦准备,
  • Cordova compile and finally
  • 科尔多瓦编译和最后
  • Cordova build
  • 科尔多瓦构建

#17


-1  

Download JDK version 8 and remove all existing versions.

下载JDK 8并删除所有现有版本。

And update Ionic.

和更新离子。

I hope your problem will be solved.

我希望你的问题能得到解决。