1

I have a Cordova/Phonegap application, every time when I rebuild the application using cordova build android it gives me below error.

ANDROID_HOME=/Users/name/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home

FAILURE: Build failed with an exception.

    * Where:
    Build file '/Users/name/Desktop/Ponet/zoomber/platforms/android/build.gradle' line: 22

    * 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 /Users/name/Desktop/Ponet/zoomber/gradle/wrapper/gradle-wrapper.properties to gradle-2.10-all.zip

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    BUILD FAILED

    Total time: 1.256 secs
    Error: Error code 1 for command: /Users/name/Desktop/Ponet/zoomber/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/name/Desktop/Ponet/zoomber/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true

Recently I have updated my Android Studio 1.5 to 2.1 and imported previous project setting. Problem can be solved if I removed my android platform and add it again and rebuild the application. But this is very time consuming to do. Please provide any suggestions or solutions?

I tried below answers: (not Cordova specific)

Gradle version 2.10 is required. Current version is 2.8 Error

Thank you in-advance!

Community
  • 1
  • 1
happycoder
  • 927
  • 3
  • 13
  • 28
  • how is "cordova build android" executed? if executed via gradlew you need to update `gradle/wrapper/gradle-wrapper.properties` to a newer version (i.e. distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip) – k3b Jul 05 '16 at 08:39
  • When I edit some thing in my project I build it again to update the changes for android platform. I'm using Webstorm and using its inbuilt terminal to do that. Is that you asked? – happycoder Jul 05 '16 at 08:44
  • search your project directories for a file containing "gradle-2.8" (i.e. a config file that says use gradle version 2.8. you need 2.10 or newer – k3b Jul 05 '16 at 08:48
  • I searched cordova project, but there is no version mentioning thing in config file (at least on config.xml). I need to get successful build when rebuild the project in cordova? not after opening the project from Android studio and then edit gradle version. – happycoder Jul 05 '16 at 09:08
  • Have you made changes in your parent gradle file? – Anurag Jul 05 '16 at 10:32
  • Where can I find parent gradle file? I'm using default gradle wrapper(since its recommended) and service directory path is /Users/name/.gradle. – happycoder Jul 05 '16 at 10:38

1 Answers1

0

Edit the /Users/name/Desktop/Ponet/zoomber/gradle/wrapper/gradle-wrapper.properties file and set the distributionUrl property to

https\://services.gradle.org/distributions/gradle-2.14-all.zip

(current version at time of writing)

larsgrefer
  • 2,735
  • 19
  • 36