Monday, December 24, 2018

Android SDK Command Line Configuration & Emulator Creation

This post contains the details about Android SDK configuration using command line tool. Using this you can avoid to install huge Android Studio setup to create android emulator.

Android SDK on Windows
-------------------------------------------------------------------------------------------------------------
1) Download Android SDK command line toos (sdk-tools-windows-4333796.zip) from the site (https://developer.android.com/studio/index.html)
2) Extracted the zip file
3) Create a directory “android-sdk” in any drive (ex -  C:\Applications\android-sdk)
4) Copy the extracted “tools” directory under the created directory (C:\Applications\android-sdk)

5) Open Command prompt and navigate to android sdk tools\bin directory (D:\Applications\android-sdk\tools\bin). 
                        Execute the command  – sdkmanager --update

6) Run the command - sdkmanager --install platform-tools


7) Now set the path of Android SDK

Update PATH variable, append platform-tools and tools folder – %ANDROID_HOME%\platforms,  %ANDROID_HOME%\platform-tools, %ANDROID_HOME%\tools\bin so that you can run the android command everywhere
Launch the command prompt and run the command to verify the correct path - adb devices


8) Launch the command prompt again and navigate to the directory “D:\Applications\android-sdk\tools\bin”
9) Run the below commands –
                sdkmanager --install "build-tools;28.0.3"
    sdkmanager --install "platforms;android-28"
    sdkmanager --install "system-images;android-28;google_apis;x86"
    sdkmanager --install "system-images;android-28;google_apis_playstore;x86"
    sdkmanager --install "system-images;android-28;google_apis_playstore;x86_64"
    sdkmanager --install "system-images;android-28;google_apis;x86_64"
    sdkmanager --install "extras;google;google_play_services"
    sdkmanage --install "add-ons;addon-google_apis-google-28"
                    sdkmanager --install "extras;intel;Hardware_Accelerated_Execution_Manager"



Note - Go to the ANDROID_HOME\extras\intel\Hardware_Accelerated_Execution_Manager directory, double click on intelhaxm-android.exe and complete the installation.
10) Once complete the above step, exit from the command prompt.
11) Installation completes.

Android SDK on Mac
------------------------------------------------------------------------------------------------
1) Download Android SDK command line toos (sdk-tools-darwin-4333796.zip) from the site (https://developer.android.com/studio/index.html)
2) Create a directory “android-sdk” under /Applications directory
3) Extracted the above download zip under the directory “/Applications/android-sdk” directory
4) Launch terminal and navigate to the directory “/Applications/android-sdk/tools/bin”
5) Run the command - ./sdkmanager --update

6) Run the command - ./sdkmanager --install platform-tools




7) Once complete the above step, exit from the current terminal.

8) Now set the path of Android SDK. Go to terminal and run the command –
                              sudo nano ~/.bash_profile
9) Copy and paste the below line (Make sure about the Android Installation directory)
       export ANDROID_SDK=/Applications/android-sdk
       export ANDROID_HOME=/Applications/android-sdk
       export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin

Save the file using Ctrl+X then Yes and quit the terminal.10) Launch the terminal again and navigate to the directory “/Applications/android-sdk/tools/bin”
11) Run the below commands
            ./sdkmanager --install "build-tools;28.0.3"
            ./sdkmanager --install "platforms;android-28"
            ./sdkmanager --install "system-images;android-28;google_apis;x86"
            ./sdkmanager --install "system-images;android-28;google_apis_playstore;x86"
            ./sdkmanager --install "system-images;android-28;google_apis_playstore;x86_64"

            ./sdkmanager --install "system-images;android-28;google_apis;x86_64"
            ./sdkmanager --install "extras;google;google_play_services"
            ./sdkmanager --install "extras;intel;Hardware_Accelerated_Execution_Manager"







Note - Go to the ANDROID_HOME/extras/intel/Hardware_Accelerated_Execution_Manager directory, double click on intelHAXM_xxx.dmg and complete the installation.
12) Installation completes

Create Android Emulator
---------------------------------------------------------------------------------------------------------------
1) Launch the terminal
2) Execute the command to create an emulator –
avdmanager  -v create avd --name testemulator --package system-images;android-28;google_apis_playstore;x86_64
Press ‘Enter’ against “profile? [no]

3) Launch the terminal. Navigate to the path ANDROID_HOME/tools
4) Launch the emulator using the command and verify its launch successfully–
emulator -avd testemulator

5) Emulator launch successfully

No comments:

Post a Comment