问题
I've installed NativeScript and I try to do tns platform add android
but it doesn't work. ANDROID_HOME path is correct and I have installed SDK (API 22 and the newest one) and tools (25.0.2). When I run tns doctor
it says:
WARNING: The Android SDK is not installed or is not configured properly.
Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 22 or later.
You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '>=25.0.2'.
You need to have Android SDK 22 or later and the latest Android Support Repository installed on your system.
回答1:
The current version of NativeScript 2.5.2 requires certain tools to be in the Android home directory so that it can detect them. The newest version of Android SDK (Mar 2017) actually removed the primary android
support file and moved several binary files into other directories to clean things up.
Unfortunately this causes NativeScript to not be able to detect that you have the SDK. This version of the SDK came out AFTER the current version of NativeScript.
The simplest way to fix this that I can think of is to start from the command line; sdkmanager
then choose to download the older 25.2.3 tools.
To manually do this; you would need to delete everything in your sdk/tools
folder and download:
https://dl.google.com/android/repository/tools_r25.2.3-windows.zip (Windows) https://dl.google.com/android/repository/tools_r25.2.3-macosx.zip (Macintosh) https://dl.google.com/android/repository/tools_r25.2.3-linux.zip (Linux)
Then extract these into that sdk/tools
directory.
回答2:
I solved this using the SDK manager in Android Studio, having already installed it previously, install all the requirements, namely
tools,platform-tools,android-25,build-tools-25.0.2,extra-android-m2repository,extra-google-m2repository,extra-android-support
Once installed change your ANDROID_HOME environment variable to point to this SDK manager. Typically, it will be at (/Users//Library/Android/sdk)
export ANDROID_HOME=/Users/<user_name>/Library/Android/sdk
Confirm that NativeScript detects your changes by running
tns doctor
来源:https://stackoverflow.com/questions/42696307/nativescript-cant-find-android-sdk-on-mac-os