apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

Could not find an installed version of Gradle #1347

Closed mlynch closed 2 years ago

mlynch commented 2 years ago

Bug Report

Problem

When running cordova platform add android@10 and then cordova build on Windows 10, this error is thrown:

Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=C:/Users/Max/AppData/Local/Android/Sdk (recommended setting)
ANDROID_HOME=C:/Users/Max/AppData/Local/Android/Sdk (DEPRECATED)
Using Android SDK: C:\Users\Max\AppData\Local\Android\Sdk
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

Similar issue as to #922 but I was not able to get it working by trying the recommended fix in that issue and, looking at the code for get_gradle_wrapper in check_reqs.js, I don't see how this will work at all on Windows as there is no gradle binary anymore AFAIK

What is expected to happen?

The Gradle check probably needs to be updated since it is no longer a binary in recent Android Studios (such as the one I'm using: Android Studio Arctic Fox : 2020.3.1)

What does actually happen?

Information

Command or Code

cordova platform add android@10 cordova build

Version information

Windows 10 Android Studio Arctic Fox : 2020.3.1 Cordova 10.0.01 cordova-android 10.1.0

breautek commented 2 years ago

Once upon a time, a gradle executable was provided by Android Studio if I recall correctly.

Now you need to install Gradle (and potentially configure the PATH system variable for command line usage / external tooling to find the binary executable) via gradle.org.

The latest should be sufficient, as we use the gradle binary to install a gradle wrapper, which is essentially a localized gradle environment using a specific gradle version that cordova-android defines.

mlynch commented 2 years ago

Okay, thanks, I see that now on the docs https://cordova.apache.org/docs/en/10.x/guide/platforms/android/

ArosPrince commented 3 months ago

I have the same problem. I'm just trying to get my project up and running on a new computer.

However, I am quite sure I have never ever installed gradle manually before. I can do what the docs say, but I'd love to understand what changed. Keeping up with the precipitous web development is so difficult. Sigh...

breautek commented 3 months ago

I am quite sure I have never ever installed gradle manually before. I can do what the docs say, but I'd love to understand what changed

I can't recall which version exactly but Android Studio used to ship with a standalone Gradle executable, and now it doesn't.

Android Studio does have access to some sort of embedded gradle, or something (not really sure how that works), so doing things while inside the Android Studio IDE works, but if you want to invoke builds outside of Android Studio, you need to have your own gradle install.