2
votes

Setup:
- VSTS build using "Hosted 2017" agent
- Cordova Build v 1.3.18
- Cordova 7.1.0
- cordova-android@^6.3.0

When building for android using the Cordova build task I get the following error:

CordovaError: Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper. Please include gradle in your path, or install Android Studio

Screenshot of complete error log

The cordova project is in a subfolder of the repository root and is specified as the Working Directory of the Cordova Build task in the build process.

VSTS Build process configuration

Investigating the drop (at d:\a\1\s\xxx) I can see that the gradle-directory is not included in the platforms\android directory. Locally this is added with "cordova add platform android" but it seem like this is not happening on VSTS. How can I solve this on the build?

Any suggestions appreciated

1
Do you solve the issue with Cordova 6.0?starian chen-MSFT

1 Answers

1
votes

It is the issue with Cordova 7.X version in Hosted agent, either gradle or android studio need to be installed for Cordova 7.X version. Check this thread: Cordova Build task fails, unable to find Gradle.

You can download and configure gradle (add to path environment variable) through PowerShell to deal with this issue (as above thread mentioned), but it needs to take some time to download and configure during each build.

If you can use lower version of Cordova (e.g. 6.0), you can choose Hosted agent (not Hosted vs2017) and leave Cordova Version input box blank.

Another way is that you can setup a private build agent with gradle or android studio installed, then queue build with this agent.