I know this is a late answer, but this issue happened to me last week, and I couldn't figure it out after following the different suggestions here. I applied the other things that mesqueeb's explains in their answer:
- Added the routes in the
PATH
- Verified that Java was there and the version was valid
- Checked that Java was linked correctly in
JAVA_HOME
The problem was that I had two different versions of the Android SDK, and the system was picking the commands from the obsolete version. I had installed it a long time back for testing and completely forgot about it.
The error happened when executing avdmanager
, so I ran the which
command to see where it was picking the executable:
which avdmanager
And there, I saw it was picking the command from usr/local/bin
instead of from the directory where I had installed the latest Android SDK. usr/local/bin
was imported into the path before the new Android SDK, so a temporary solution was to replace the order of the PATH
: instead of appending the new Android SDK paths at the end of the PATH
, I prepended them to the beginning:
PATH=$HOME/Library/Android/Sdk/emulator:$PATH
PATH=$HOME/Library/Android/Sdk/tools:$PATH
PATH=$HOME/Library/Android/Sdk/tools/bin:$PATH
PATH=$HOME/Library/Android/Sdk/platform-tools:$PATH
export ANDROID_HOME=$HOME/Library/Android/
That solved the problem. Ultimately, I ended up uninstalling the old version (I didn't need it anymore). I had used Brew cask to install it, so I ran the following command:
brew uninstall --cask android-sdk
(Notice that if you have a similar issue, the uninstalling process will depend on how you installed the Android SDK. In my case, it was brew, but you may have used a different method.)