Reputation: 139
I am trying to build my android app and am getting an error about the version of Gradle that is being used. When I make the change that is suggested and run the command again the change gets changed back causing it to fail again.
I have tried replacing all references to gradle-4.1-all.zip
with gradle-4.10.1-all.zip
and for some reason it keeps getting changed back at this location /gradle/wrapper/gradle-wrapper.properties to gradle-4.10.1-all.zip
Android Studio project detected ANDROID_HOME=/Users/user.account/Library/Android/sdk JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home studio Subproject Path: CordovaLib Subproject Path: app
FAILURE: Build failed with an exception.
Where: Build file '/Users/user.account/cordovaProjects/hybrid-base/platforms/android/CordovaLib/build.gradle' line: 41
What went wrong: A problem occurred evaluating project ':CordovaLib'.
Failed to apply plugin [id 'com.android.library'] Minimum supported Gradle version is 4.10.1. Current version is 4.1. If using the gradle wrapper, try editing the distributionUrl in /Users/user.account/cordovaProjects/hybrid-base/gradle/wrapper/gradle-wrapper.properties to gradle-4.10.1-all.zip
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 0s /Users/user.account/cordovaProjects/hybrid-base/platforms/android/gradlew: Command failed with exit code 1 Error output: FAILURE: Build failed with an exception.
Where: Build file '/Users/user.account/cordovaProjects/hybrid-base/platforms/android/CordovaLib/build.gradle' line: 41
What went wrong: A problem occurred evaluating project ':CordovaLib'.
Failed to apply plugin [id 'com.android.library'] Minimum supported Gradle version is 4.10.1. Current version is 4.1. If using the gradle wrapper, try editing the distributionUrl in /Users/user.account/cordovaProjects/hybrid-base/gradle/wrapper/gradle-wrapper.properties to gradle-4.10.1-all.zip
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 0s
I am able to get a build to work if I do a cordova platform remove android
and then immediately cordova platform add android
but as soon as I try to build a second time it fails
Upvotes: 1
Views: 5297
Reputation: 2363
If for any reason you need a different version of gradle there is no need to edit any file, just set the CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL env var with value the url where to fin the gradle zip, for example
http://services.gradle.org/distributions/gradle-4.1-all.zip
I do not have any problem with version 4.1 ( win10, android platform 7.1.4 ).
After you set your desired gradle version, reset your project ( remove all plugin and all platforms and manual edits then reinstall ) and then try to build.
If the problem persist, to help you better, post the error and please specify which OS, cordova version and android platform version you are using.
As a rule of thumb, from my experience with cordova, when you think that the only way to set a certain configuration is to edit platform files, there is probably a proper way to do so ( for example to automatically sign the apk when build )
Upvotes: 2