Skip to main content
 

Error: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.

3 min read

This error has plagued me for a week now.  Everything was working fine until Android Studio decided to prompt me for updates which I did.  Then suddenly I can't build any android apks with cordova.  The frustrating thing is the wording of this error is so common for misconfigurations that trying to track down a solution has been an exercise of pure frustration.

After much digging around and trial and error what appears to have happened is the latest build of Android Studio has changed the file structure of how it's storing the sdk such that cordova can't find all of the required files even if the $ANDROID_HOME system variable is correct which makes the error message even more difficult as it points to an incorrect root cause of the error.

So for anyone else running into this - I completely nuked Android Studio.  I was only using it for the sdk manager anyway.  As far as I can tell Android Studio in it's current format won't work with cordova cli.

Delete the entire contents of ~/Library/Android/sdk

I downloaded the command line tools package from here: https://dl.google.com/android/repository/tools_r25.2.3-macosx.zip (as per the page: https://developer.android.com/studio/index.html).  Note that this location is new since the latest release and as of this writing many search results for command line tools installation are out of date.

 

Unzip the file and copy the resulting tools directory to ~/Library/Android/sdk/tools

Open up the sdk manager with

~/Library/Android/sdk/tools/android sdk

With the sdk manager I installed:

API 25

- SDK Platform

- Android TV Intel x86 Atom System Image

- Google APIs ARM 64 v8a System Image

- Google APIs ARM EABI v7a System Image

- Google APIs Intel x86 Atom_64 System Image

- Sources for Android SDK

API 22

- SDK Platform

- Sources for Android SDK

API 21

- SDK Platform

- Sources for Android SDK

 

After attempting a new build it looks like it got further but I was greeted with an error of: Error: Please install Android target: "android-23".

So I additionally installed

API 23

- SDK Platform

 

Next build - new error:

 

FAILURE: Build failed with an exception.

 

* What went wrong:

A problem occurred configuring root project 'android'.

> Could not resolve all dependencies for configuration ':_armv7DebugCompile'.

 

Followed by a list of cordova plugins that had errored out on the build.  I took the armv7 part of that as a hint and installed:


API 23

- Google APIs ARM EABI v7a System Image

 

When that didn't work, I tried to be smarter and searched for solution first - stackoverflow had at least one resolved hit: http://stackoverflow.com/questions/33675491/could-not-resolve-all-dependencies-for-configuration-armv7debugcompile

So I installed:

 

Extras

- Android Support Repository

- Google Play Services

- Google Repository

 

Finally I got a build to work.  I have yet to test the resulting apk, but I'm assuming it's good.