Android SDK and Android Studio Setup Tutorial
This tutorial will guide you through setting up Android SDK and Android Studio for developing Android applications, with a focus on supporting C++ development with NDK.
Prerequisites
- System Requirements: Windows 10/11, macOS 10.14+, or Linux (Ubuntu 18.04+ recommended)
- RAM: Minimum 8GB, recommended 16GB+
- Storage: At least 4GB for Android Studio + additional space for SDK components
- Java: JDK 8 or higher (Android Studio includes OpenJDK)
Step 1: Download and Install Android Studio
Download Android Studio
- Visit the Android Studio official website
- Click "Download Android Studio"
- Accept the terms and conditions
- Download the installer for your operating system
Install Android Studio
Windows:
# Run the downloaded .exe file
# Follow the installation wizard
# Choose "Standard" installation type
macOS:
# Open the downloaded .dmg file
# Drag Android Studio to Applications folder
# Launch Android Studio from Applications
Linux:
# Extract the downloaded .tar.gz file
tar -xzf android-studio-*.tar.gz
# Navigate to the android-studio/bin directory
cd android-studio/bin
# Run the studio.sh script
./studio.sh
Step 2: Initial Android Studio Setup
- Launch Android Studio
- Setup Wizard: Choose "Standard" setup for most components
- SDK Components: The wizard will download:
- Android SDK
- Android SDK Platform-Tools
- Android SDK Build-Tools
- Android Emulator
- Android SDK Platform (latest API level)
Step 3: Install Android NDK for C++ Development
Through Android Studio
- Open Android Studio
- Go to File → Settings (Windows/Linux) or Android Studio → Preferences (macOS)
- Navigate to Appearance & Behavior → System Settings → Android SDK
- Click the SDK Tools tab
- Check the following items:
- NDK (Side by side)
- CMake
- LLDB
- Click Apply and OK to install
Verify NDK Installation
# Check NDK installation path
# Default locations:
# Windows: %LOCALAPPDATA%\Android\Sdk\ndk\[version]
# macOS: ~/Library/Android/sdk/ndk/[version]
# Linux: ~/Android/Sdk/ndk/[version]
# Set environment variable (add to your shell profile)
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/[version]
Step 4: Configure SDK Manager
- Open Tools → SDK Manager
- SDK Platforms tab: Install desired API levels (recommended: API 21+ for modern apps)
- SDK Tools tab: Ensure these are installed:
- Android SDK Build-Tools (latest)
- Android SDK Platform-Tools
- Android SDK Tools
- NDK (Side by side)
- CMake
- LLDB (for debugging C++ code)
Step 5: Set Up Android Virtual Device (AVD)
Create an Emulator
- Open Tools → AVD Manager
- Click Create Virtual Device
- Select a device definition (e.g., Pixel 4)
- Choose a system image:
- API Level: 21+ recommended
- ABI: x86_64 (for better performance) or arm64-v8a (for ARM testing)
- Configure AVD settings:
- RAM: 2GB+ recommended
- Internal Storage: 2GB+ recommended
- Click Finish
Launch Emulator
# From command line (optional)
emulator -avd [AVD_NAME]
Step 6: Configure Environment Variables
Windows
# Add to System Environment Variables
ANDROID_HOME=C:\Users\[username]\AppData\Local\Android\Sdk
ANDROID_NDK_HOME=%ANDROID_HOME%\ndk\[version]
# Add to PATH
%ANDROID_HOME%\platform-tools
%ANDROID_HOME%\tools
%ANDROID_NDK_HOME%
macOS/Linux
# Add to ~/.bashrc, ~/.zshrc, or ~/.profile
export ANDROID_HOME=$HOME/Library/Android/sdk # macOS
# export ANDROID_HOME=$HOME/Android/Sdk # Linux
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/[version]
export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$ANDROID_NDK_HOME
Step 7: Verify Installation
Check SDK Installation
# Verify SDK installation
adb version
android --version # Deprecated but may be available
# List installed packages
sdkmanager --list
Check NDK Installation
# Navigate to NDK directory and check
ls $ANDROID_NDK_HOME
# Verify NDK tools
$ANDROID_NDK_HOME/ndk-build --version
Step 8: Create Your First Android Project with C++ Support
- Start New Project: Click "Start a new Android Studio project"
- Choose Template: Select "Native C++" template
- Configure Project:
- Name: Your app name
- Package name: com.example.yourapp
- Language: Java/Kotlin (for Android part)
- Minimum SDK: API 21+ recommended
- Configure C++ Support:
- C++ Standard: C++14 or higher
- Toolchain Default: clang (recommended)
- Click Finish
Step 9: Test the Setup
Build and Run Test Project
- Wait for Gradle sync to complete
- Connect a physical device or start an emulator
- Click the Run button (green play icon)
- Verify the app launches successfully
Verify C++ Integration
The Native C++ template includes:
app/src/main/cpp/directory for C++ source filesCMakeLists.txtfor build configuration- JNI bridge for Java/Kotlin ↔ C++ communication
Common Issues and Troubleshooting
Issue: NDK not found
# Solution: Verify NDK path in local.properties
echo "ndk.dir=$ANDROID_NDK_HOME" >> local.properties
Issue: Emulator performance
- Enable Hardware Acceleration (Intel HAXM/AMD Processor)
- Allocate sufficient RAM to emulator
- Use x86_64 system images when possible
Issue: Gradle sync failed
- Check internet connection
- Update Gradle wrapper if needed
- Clear cache: File → Invalidate Caches and Restart
Next Steps
With Android Studio and NDK properly configured, you're ready to:
- Develop Android applications with C++ backend
- Integrate gRPC for network communication
- Use Vulkan for high-performance graphics
- Build complex native applications
Summary
This tutorial covered:
- Installing Android Studio
- Setting up Android SDK and NDK
- Configuring development environment
- Creating Android projects with C++ support
- Troubleshooting common issues
You now have a complete Android development environment ready for advanced features like gRPC and Vulkan integration.
Content Review
The content in this repository has been reviewed by chevp. Chevp is dedicated to ensuring that the information provided is accurate, relevant, and up-to-date, helping users to learn and implement programming skills effectively.
About the Reviewer
For more insights and contributions, visit chevp's GitHub profile: chevp's GitHub Profile.