Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
531 views
in Technique[技术] by (71.8m points)

Cordova build changes distributionUrl in gradle-wrapper.properties file

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:UsersProjectgradlewrappergradle-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 ?

question from:https://stackoverflow.com/questions/37125496/cordova-build-changes-distributionurl-in-gradle-wrapper-properties-file

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As could be guessed, there is a script that is being run behind the scene when you issue the "Cordova build android" command. This script needs 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 line including the following variable in the file:

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, and there you go!

inspired from the following SO; install gradle for using in cordova build android


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...