Keywords: Android SDK | macOS | Homebrew | Environment Variables | Development Environment Configuration
Abstract: This article provides a comprehensive guide to installing and configuring Android SDK on macOS systems. It focuses on using Homebrew Cask for Android SDK installation, including essential environment variable configuration and path settings. The article analyzes the pros and cons of different installation methods, offers detailed command-line operations and configuration examples, and helps developers quickly set up their Android development environment. Combined with Android Studio system requirements, it delivers complete technical guidance.
Choosing the Installation Location for Android SDK on macOS
When installing Android SDK on macOS systems, selecting an appropriate installation location is crucial for subsequent development and maintenance. Based on community best practices and tool evolution, using package managers is the most recommended approach.
Installing Android SDK Using Homebrew Cask
Homebrew, as the most popular package manager on macOS, provides a simple and efficient way to install software. With changes in Android SDK maintenance, it now requires installation through Homebrew Cask.
First, add the Cask repository to Homebrew:
brew tap homebrew/cask
Then install Android SDK using the following command:
brew install android-sdk --cask
Environment Variable Configuration
After installation, you must configure the ANDROID_HOME environment variable to point to the SDK installation location. On macOS, the default location for Android SDK installed via Cask is:
export ANDROID_HOME=/usr/local/share/android-sdk
This configuration needs to be added to the user's shell configuration file, depending on the shell type:
- For Zsh users:
~/.zshrc - For Bash users:
~/.bashrcor~/.bash_profile
Custom Installation Location
While using package managers is the best practice, developers might prefer to install Android SDK in custom locations under certain circumstances. A common custom path is:
~/opt/local/android-sdk-mac
When choosing a custom location, ensure:
- The path has appropriate read-write permissions
- ANDROID_HOME environment variable correctly points to this location
- Development tools can properly recognize the SDK path
System Requirements and Compatibility
Before installing Android SDK, ensure your system meets basic requirements. According to official documentation, macOS systems require:
- Operating System: macOS 12 or later (latest 64-bit version recommended)
- Memory: 8GB for Android Studio only, 16GB including emulator
- Processor: Apple M1 chip or 6th generation Intel Core and above
- Disk Space: 8GB free space for Android Studio only, 16GB including emulator
Installation Verification and Testing
After installation, verify that Android SDK is correctly installed using the following commands:
echo $ANDROID_HOME
ls -la $ANDROID_HOME
If configured correctly, you should see a list of files and folders in the SDK directory. Additionally, test the complete development environment by running Android Studio and creating a new project.
Common Issues and Solutions
Some common issues you might encounter during installation:
- If Homebrew cannot find android-sdk, ensure the Cask repository is properly added
- After environment variable configuration, reload shell configuration:
source ~/.zshrcorsource ~/.bashrc - Permission issues can be resolved using
chmodcommands to adjust directory permissions
Conclusion
Installing Android SDK via Homebrew Cask is currently the best practice on macOS, as it simplifies the installation process and ensures proper dependency management. Correct environment variable configuration and path selection are essential for subsequent Android development work. Developers should choose appropriate installation locations based on their needs and ensure system configuration is correct.