Using Android SDK: undefined

Hi, my project was developed in Ionic 3 with Cordova 9 and later Cordova 11.

I’ve been maintaining it for several years without any major issues, but now I needed to replace the computer.

So I cloned the repo on my new PC, but for the live of me I am just not able to get it working. I’ve spent 3 days already trying to install all the deps so that I can least run ionic serve (the usual issues with node-sass compilation, Python2 and VS2017 dependency and all that). I was successful with that in the end, but now I’m stuck on this issue when trying to run ionic cordova build android. What I get is this:

Checking Java JDK and Android SDK versions
ANDROID_HOME=c:\Users\Aros\AppData\Local\Android\Sdk\ (recommended setting)
ANDROID_SDK_ROOT=undefined (DEPRECATED)
Using Android SDK: undefined
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
[ERROR] An error occurred while running subprocess cordova.

        cordova.cmd build android exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.

--verbose flag doesn’t seem to display any more useful info on top of that.

The path to Android studio is OK as far as I can tell.
My JAVA_HOME points to C:\Program Files\Android\Android Studio\jbr and there’s Java 17.0.6.
I guess the problematic part might be Using Android SDK: undefined but I wasn’t able to google what’s the problem with that. I’d expect it’s supposed to be set based on where ANDROID_HOME points to.

Also I don’t understand the Gradle problem. Gradle is supposed to be installed with Android studio, shouldn’t it?

BTW I’ve been following instructions here Android Platform Guide - Apache Cordova

… including the recommended stuff to add in the PATH. No luck still.

Anything else I could do?

Thanks!
Jan

//Edit: Maybe a few more details…
I am using nvm because of other projects that require different node version. This project I’m trying to setup with 16.20.2. I think before that on the previous computer I was running version 14, but some of the deps (don’t remember now exactly) or maybe npm itself were complaining that it’s out of support and wouldn’t run. That’s the reason for switching to 16. That’s probably not the problem now though as this has probably nothing to do with the env setup I seem to be facing.

Ionic info:

Ionic:

   Ionic CLI          : 6.20.9 (C:\Users\Aros\AppData\Roaming\nvm\v16.20.2\node_modules\@ionic\cli)
   Ionic Framework    : ionic-angular 3.9.5
   @ionic/app-scripts : 3.2.2

Cordova:

   Cordova CLI       : 12.0.0 (cordova-lib@12.0.1)
   Cordova Platforms : android 11.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, (and 3 other plugins)

Utility:

   cordova-res : not installed globally
   native-run  : not installed globally

System:

   Android SDK Tools : 26.1.1 (c:\Users\Aros\AppData\Local\Android\Sdk\)
   NodeJS            : v16.20.2 (C:\Program Files\nodejs\node.exe)
   npm               : 8.19.4
   OS                : Windows 10

BTW it says Windows 10, but actually it’s Windows 11. That’s probably also irrelevant though…

OK, so the solution to this one is actually to download gradle binaries and add the bin folder to the PATH.

More info here: Could not find an installed version of Gradle · Issue #1347 · apache/cordova-android · GitHub