Unable to build an android gradle project - for a

2020-06-03 07:42发布

I am unable to build a gradle project, even if I edit the gradle property, I get the following error:

Error:(22, 1) 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\salangar\angular-cordova-tickrv0.1\platforms\android\gradle\wrapper\gradle-wrapper.properties to gradle-2.10-all.zip

How do I resolve this?

6条回答
该账号已被封号
2楼-- · 2020-06-03 07:57

Edit $(your app path)/platform/android/gradle/wrapper/gradle-wrapper.properties: find:

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

Change to:

distributionUrl=http\://services.gradle.org/distributions/gradle-2.10-all.zip
查看更多
Deceive 欺骗
3楼-- · 2020-06-03 07:58

it will always generate same file every times you run build, so the way to handle it find the generator .. in my case App Location> platform > android> cordova >lib> builders> Gradlebuilder.js and find this ..

var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\: '

after edit it, every time code generate will create new distribution url you make.

查看更多
冷血范
4楼-- · 2020-06-03 08:04

I discovered the issue here. Android Studio asks to upgrade gradle. Don't do that ! I've made a bug report. The version has to keep being updated in Android Studio after each rebuild on the command line.

File -> Project Structure -> Project. Need to keep changing it to 2.10. There is not one fix for this yet that I've seen.

查看更多
神经病院院长
5楼-- · 2020-06-03 08:07

Instead of manipulating build.js file, the easiet approach would be as follows:

1) Download required gradle version and save it local folder.

2) In command prompt execute the following command:
export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL=file:///local/path/to/folder/where/gradle/zip/is/saved/gradle-2.2.1-all.zip

3) Execute the following command: cordova run android

查看更多
我想做一个坏孩纸
6楼-- · 2020-06-03 08:15

I was also getting the same error and modifying the
$(your app path)/platform/android/gradle/wrapper/gradle-wrapper.properties to

distributionUrl=http\://services.gradle.org/distributions/gradle-2.10-all.zip

didn't help as it was getting overridden every time i ran cordova build android to 2.2.1

I finally changed the gradleBuilder.js file under $(your app path)/platforms/android/cordova/lib/builders folder.

Search for distributionUrl and change it 2.10.

This triggered download of gradle-2.10 and compilation went through. At least it worked for me.

查看更多
趁早两清
7楼-- · 2020-06-03 08:22

I use sencha touch 2.4.2 and cordova 5.4.1.

I had the same error because the Sencha-Cmd:

sencha app build native always rewrite the file: $(your app path)/cordova/platform/android/gradle/wrapper/gradle-wrapper.properties

And reset the variable distributionUrl to the old bad value: distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip

To solve that, i have changed the variable distributionUrl, directly in the file: $(your app path)/cordova/platforms/android/cordova/lib/build.js at line 346 change build.js:

// New good value
var distributionUrl = 'distributionUrl=http\\://services.gradle.org/distributions/gradle-2.10-all.zip';
// Old bad value
// var distributionUrl = 'distributionUrl=http\\://services.gradle.org/distributions/gradle-2.2.1-all.zip';

And that permanently solve the problem and i can now have a successful native build for Android ;)

查看更多
登录 后发表回答