Android SDK & AVD Setup Guide

A comprehensive step-by-step guide to setting up Android SDK and AVD for seamless development.
Follow each step meticulously, for more detailed check README.MD and refer to the contact details in the footer for assistance.

1. Download SDK tools package and Set Environment Variables

Step 1: Download Command line tools and Unzip the Android SDK

  1. Go to the Android SDK Download Page.
  2. Download the Command Line Tools (CLI) for your operating system.
  3. Extract the ZIP file to a directory (e.g., C:\AndroidSDK or ~/Android/sdk).
  4. Set the path (e.g., C:\AndroidSDK\cmdline-tools\bin or ~/Android/sdk/cmdline-tools/bin).

Step 2: Set the SDK Path as a System Variable

For Windows:

  1. Open "Control Panel" > "System" > "Advanced System Settings."
  2. Click "Environment Variables" and add a new variable:

For macOS:

  1. Open the .bash_profile or .zshrc file:
  2. nano ~/.zshrc
  3. Add these lines:
  4. export ANDROID_HOME=~/Android/sdk
    export ANDROID_SDK_ROOT=~/Android/sdk
    export PATH=$PATH:$ANDROID_HOME/platform-tools
  5. Apply changes with:
  6. source ~/.zshrc

2. Install Platform-tools, Platforms and Build Tools for Android 34

sdkmanager "platform-tools"
sdkmanager "platforms;android-34"
sdkmanager "build-tools;34.0.0"
  • Add System variable C:\AndroidSDK\platform-tools & C:\AndroidSDK\platforms
  • 3. Install System Images and Create an AVD

    Install System Images:

    sdkmanager "system-images;android-34;google_apis;x86_64"
    sdkmanager --licenses
  • Add System variable to the Emulator (e.g., C:\AndroidSDK\emulator).
  • Create a New AVD:

    avdmanager create avd --name "MyAVD" --package "system-images;android-34;google_apis;x86_64"

    4. List Emulators

    emulator -list-avds
    List Emulators Output
    C:\Users\username>emulator -list-avds
    MyAvd

    5. Run Emulator

    emulator -avd MyAVD 

    Run Emulator by full Strength:

    emulator -avd MyAVD -netdelay none -netspeed full -gpu on -memory 4096 -cores 4 -no-snapshot-load -feature KeyboardSupport

    Command Explanation:

    Common AVD Commands:

    to configure the harder of AVD, your can do that from your avd's config.ini file
    C:\Users\username\.android\avd\yourAdvname.avd\



    Other AVD Commands


    Force Kill an Emulator

    to get the Emulator devices

    adb devices
    ADB Devices Output
    C:\Users\"username">adb devices
    List of devices attached
    emulator-5554   device
            

    Kill Emulator

    adb -s emulator-5554 emu kill

    Update SDK and AVD

    Update All SDK Components:

    sdkmanager --update

    Update the Emulator:

    sdkmanager "emulator"

    Start and Stop the ADB Server

    adb kill-server
    adb start-server

    Pull and Push Files to/from AVD

    Check File Existence on AVD:

    adb shell mkdir /sdcard/Download
    Output
    C:\Users\username>adb shell mkdir /sdcard/Download
    mkdir: '/sdcard/Download': File exists

    Pull Files:

    adb pull /sdcard/Download/ C:\AVDFiles

    Push Files:

    adb push C:\AVDFiles\myfile.txt /sdcard/Download/

    Uninstall AVD & SDK Components

    Uninstall AVD

    avdmanager delete avd -n MyAVD
    sdkmanager --uninstall "build-tools;34.0.0" "platforms;android-34" "system-images;android-34;google_play;x86_64"