Mac(macOS10.14.2)下Ionic安卓模拟器运行报错求助
android Command on macOS Hey there, I totally get the frustration—Google phased out the old android command a while back, so we need to use the newer, dedicated tools to get your Android emulator set up for Ionic/Cordova. Let's walk through this step by step:
1. Verify & Set Up Android SDK Environment Variables
First, make sure your SDK path is correctly configured in your shell profile (.bash_profile, .zshrc, or whatever you use). Add these lines to the file:
export ANDROID_SDK_ROOT=/Users/manishkumar/Library/Android/sdk export PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/emulator
Save the file, then reload it with:
source ~/.bash_profile # or source ~/.zshrc if you use zsh
2. Download Required System Images & Tools with sdkmanager
The sdkmanager replaces the old android sdk command. First, list all available packages to see what you need:
$ANDROID_SDK_ROOT/tools/bin/sdkmanager --list
Then download a system image (pick an API level compatible with your Ionic project—we'll use Android 29 as an example) plus essential tools:
$ANDROID_SDK_ROOT/tools/bin/sdkmanager "system-images;android-29;google_apis;x86_64" "platforms;android-29" "emulator" "platform-tools" "tools"
3. Create an AVD with avdmanager
Now use avdmanager (the replacement for android avd) to create your emulator. First, list the targets you just downloaded:
$ANDROID_SDK_ROOT/tools/bin/avdmanager list targets
Then create your AVD (name it something memorable like MyIonicEmulator):
$ANDROID_SDK_ROOT/tools/bin/avdmanager create avd -n MyIonicEmulator -k "system-images;android-29;google_apis;x86_64"
Follow the prompts to configure storage size and hardware settings—you can stick with defaults if you're unsure.
4. Launch the Emulator & Test Your Ionic Build
Start the emulator with:
emulator -avd MyIonicEmulator
If it's slow, enable hardware acceleration by installing HAXM first:
# Install HAXM via sdkmanager $ANDROID_SDK_ROOT/tools/bin/sdkmanager "extras;intel;Hardware_Accelerated_Execution_Manager" # Run the HAXM installer open /Users/manishkumar/Library/Android/sdk/extras/intel/Hardware_Accelerated_Execution_Manager/HAXM\ installation
Once the emulator is running, try your Ionic command again:
ionic cordova emulate android
If it still doesn't pick up the emulator, specify it directly:
ionic cordova emulate android --target=MyIonicEmulator
Why the Old android Command Didn't Work
Google deprecated the all-in-one android command in favor of specialized tools like sdkmanager and avdmanager to make SDK management more modular. That's why you got errors like "Invalid or unsupported command 'sdk'"—those old subcommands are no longer supported.
内容的提问来源于stack exchange,提问作者manish kumar

