apache / cordova-android

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

Detected 'avdmanager' command but no 'tools\bin' directory found near. #1707

Closed nishantshah977 closed 1 week ago

nishantshah977 commented 1 week ago

Bug Report

Problem

ANDROID_HOME=undefined (recommended setting)
ANDROID_SDK_ROOT=undefined (DEPRECATED)
Failed to find 'ANDROID_HOME' environment variable. Try setting it manually.
Detected 'avdmanager' command at C:\Users\ASUS\AppData\Local\Android\Sdk\cmdline-tools\latest\bin but no 'tools\bin' directory found near.
Try reinstall Android SDK or update your PATH to include valid path to SDK\tools\bin directory.

Information

I'm on windows 11. JAVA_SDK error is due to Java 14 instead of Java 8.

Even though I've installed all the required sdks and configured all environment variables properly from docs. I'm still getting the error.

Command or Code

cordova run android

Environment, Platform, Device

OS: Windows

Version information

"cordova-android": "^12.0.1",

Checklist

breautek commented 1 week ago

JAVA_SDK error is due to Java 14 instead of Java 8.

On modern tooling, JDK 11 is the minimum required version, though JDK 17 would be recommended.

You don't have the ANDROID_HOME environment variable defined, therefore cordova has to guess where your android SDK is installed. It's usually better if this is explicitly defined. Based on your output it looks like it's located at C:\Users\ASUS\AppData\Local\Android\Sdk

If have an opened command prompt/powershell, they will need to be re-opened after changing environment variables. Environment variables are loaded only when they are opened and will not automatically receive environment variable updates.

There is a problem with cordova docs suggesting you to install the latest command-line tools, but the latest version requires JDK 17. So you either need to use JDK 17, or use command-line tools version 10.0, and uninstall any other versions that is installed.

If you have the Android SDK Tools (Obsolete) installed, then I'd also recommend uninstalling that. Those are the tools that only run on JDK 8 and they won't work with modern Android SDKs or run modern Android emulator images.

nishantshah977 commented 1 week ago

Thanks a lot it solved my issue.

Steps to reproduce

  1. Set ANDROID_HOME variable (In my case I've tried to save it but I've clicked cancel instead of OK)
  2. Download JAVA 17
  3. Add Gradle Path