Cordova build在gradle-wrapper.properties文件中更改distributionUrl [英] Cordova build changes distributionUrl in gradle-wrapper.properties file
问题描述
当我执行
时,我仍然收到以下建立异常 cordova run android --verbose
- 出错:
评估根项目android时出现问题。
无法应用插件[id'android']
Gradle版本2.10是必需的。当前版本为2.2.1。如果使用gradle包装器,请尝试将C:\Users\Project\gradle\wrapper\gradle-wrapper.properties中的distributionUrl编辑为gradle-2.10-all.zip
< blockquote>
这样做的原因是当我运行cordova build命令时,
distributionUrl = http\://services.gradle.org/distributions/gradle-2.1.0-all.zip
到
distributionUrl = http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
以任何方式防止这种情况?
可以猜测,当你发出cordova build android命令运行。这是为了查看为gradle版本指定的配置。
您必须前往并检查以下js文件:
$ PROJECT_ROOT / platforms /android/cordova/lib/builders/GradleBuilder.js
然后找到以下变量:
GradleBuilder.prototype.prepEnv
的分配变量:
var distributionUrl = process.env ['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'http\\://services.gradle.org/distributions/gradle-2.2.1-all.zip';
这是你正在寻找什么,你需要更改为gradle-2.10-all.zip url ;
现在你可以运行build命令了。
遵循SO;
安装gradle以在cordova版本中使用android
I keep getting the following build exception when I run
cordova run android --verbose
- What went wrong:
A problem occurred evaluating root project 'android'.
Failed to apply plugin [id 'android'] Gradle version 2.10 is required. Current version is 2.2.1. If using the gradle wrapper, try editing the distributionUrl in C:\Users\Project\gradle\wrapper\gradle-wrapper.properties to gradle-2.10-all.zip
The reason for this is the line being changed when I run the cordova build command from;
distributionUrl=http\://services.gradle.org/distributions/gradle-2.1.0-all.zip
to
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
Any way to prevent this ?
As could be guessed, there is a script that is being run when you issue the "cordova build android" command. This was to be found in order to see the config specified for gradle version.
You must go and check the following js file:
$PROJECT_ROOT/platforms/android/cordova/lib/builders/GradleBuilder.js
Then find the following variable:
GradleBuilder.prototype.prepEnv
And check the distributionUrl variable:
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'http\\://services.gradle.org/distributions/gradle-2.2.1-all.zip';
That's what you are looking for and what you need to change to gradle-2.10-all.zip url;
Now you can run the build command, there you go !
This is the answer provided by the following SO; install gradle for using in cordova build android
这篇关于Cordova build在gradle-wrapper.properties文件中更改distributionUrl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!