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

I am having problem to build android with Cordova, when I execute cordova build android, I receive this error:

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.

I have do this to fix it:

  • Getting vbox guest addtions for android x86
  • VS2013 Cordova blank app command failed with exit code 8 error
  • Inner classes: Android vs Java
  • HTTPS connection with client certificate in an android app
  • Shouldn't there be an option for Fragments to retain click events within their view hierarchy?
  • Google Play security alert for insecure TrustManager
  • sudo nano  ~/.bash_profile
    

    and add this line:

    export PATH=${PATH}:/Users/myname/Library/Android/sdk/platform-tools:/Users/myname/Library/Android/sdk/tools
    

    then this:

    source ~/.bash_profile
    

    but I get again that error when I build, how can I fix it?

    UPDATE:

    This is the line I Added in the bash:

    export PATH=${PATH}:/Users/myname/Library/Android/sdk/platform-tools:/Users/myname/Library/Android/sdk/tools
    export ANDROID_HOME=/Users/myname/Library/Android/sdk
    

    Related posts:

    RecyclerView.Adapter.notifyItemChanged() never passes payload to onBindViewHolder()
    Unexplained gap/padding to the left, between Toolbar, and LinearLayout
    Are there any tools to convert an Iphone localized string file to a string resources file that can b...
    How to get complete address from latitude and longitude?
    How to get an enum which is created in attrs.xml in code
    Multiple Info Windows in Android Maps API 2
  • What do you need to pass to v4.widget.DrawerLayout.isDrawerOpen()/.openDrawer()/.closeDrawer()
  • Defragment H264 NAL stream (Originally 1722 avb packets)
  • Should we prefer AdMob in Google Play services compared to “old” AdMob SDK
  • Expandable Item in List on Android
  • Read ID3 Tags of an MP3 file
  • Send Data from Service To Activity Android
  • 4 Solutions collect form web for “Cordova: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable”

    The recent Android SDK tools removed the android command.

    $ android -v
    The android command is no longer available.
    For manual SDK and AVD management, please use Android Studio.
    For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
    

    cordova is behind the change and someone seems to be working on it: https://issues.apache.org/jira/browse/CB-12554

    You can also downgrade your tools to a version where the android was still available.

    Nevertheless, I found a way to run the Android app without having to downgrade my SDK tools. I would (1) run cordova prepare, then (2) run the command I need from Android Studio. In my case, running it on the emulator was enough.

    UPDATE: The issue CB-12554 is resolved now and was released with the cordova-android@6.2.0 release.

    UPDATE: There were several related subsequent patches done and the newest version is cordova-android@6.2.3. Run cordova platform rm android; cordova platform add android@6.2.3 to fix the issues.

    For me this work , first check your cordova android version

    cordova platform version android
    

    it shows 5.0 to me and after that upgrade the version by this command

    cordova platform update android
    

    @Rjak here is the manual for downgrading SDK version with valid links for older SDK versions. It works for me with same issue, after downgraded to tools v25.2.5 & platform-tools to v25.0.3 build successful

    I solved my question uninstalling Android Studio and install the CLI SDK Manager following this guide:

    https://guides.codepath.com/android/Installing-Android-SDK-Tools

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.