September 17, 2013

Android Virtual Device (AVD) Emulator Creation and Installing APK on Emulator Using Command Line

Dear friends,

Every time whenever we are using most of the Android developers are using Eclipse or some other IDE to create and start the AVD.

I was just thought of using it via command line in my Ubuntu because I was very lazy to start and wait for Eclipse to get ready. I just want to try some apk on Emulator.

Ubuntu Procedure


Open terminal
I was hoping that you had already included the Android tools, platform-tools in PATH. If not just do that else navigate to Android SDK directory

Create AVD:

Syntax: 
$ android create avd -n -t --abi

target-ids are based on the installed Android platforms. Its not the Android API Level.

abi(Application Binary Interface): The ABI is used to control which machine code will run on a given hardware device. For example, for an Android application to run on an x86 device, it is necessary to include x86 ABI support when compiling the application.

Example:
$ android avd -n MyJB -t 12 --abi armeabi-v7a

To view the target-ids list and supported ABI for target-id, execute the following command

$ android list targets

You might be getting some output similar to this

Available Android targets:
----------
id: 1 or "android-3"
     Name: Android 1.5
     Type: Platform
     API level: 3
     Revision: 4
     Skins: HVGA-P, QVGA-L, HVGA-L, HVGA (default), QVGA-P
     ABIs : armeabi
----------
id: 2 or "android-4"
     Name: Android 1.6
     Type: Platform
     API level: 4
     Revision: 3
     Skins: HVGA, QVGA, WVGA800 (default), WVGA854
     ABIs : armeabi
----------
id: 3 or "android-7"
     Name: Android 2.1
     Type: Platform
     API level: 7
     Revision: 3
     Skins: HVGA, QVGA, WQVGA432, WVGA800 (default), WQVGA400, WVGA854
     ABIs : armeabi
----------
id: 4 or "android-8"
     Name: Android 2.2
     Type: Platform
     API level: 8
     Revision: 3
     Skins: HVGA, QVGA, WQVGA432, WVGA800 (default), WQVGA400, WVGA854
     ABIs : armeabi
----------
id: 5 or "android-10"
     Name: Android 2.3.3
     Type: Platform
     API level: 10
     Revision: 2
     Skins: HVGA, QVGA, WQVGA432, WVGA800 (default), WQVGA400, WVGA854
     ABIs : armeabi, x86
----------
id: 6 or "android-11"
     Name: Android 3.0
     Type: Platform
     API level: 11
     Revision: 2
     Skins: WXGA (default)
     ABIs : armeabi
----------
id: 7 or "android-12"
     Name: Android 3.1
     Type: Platform
     API level: 12
     Revision: 3
     Skins: WXGA (default)
     ABIs : armeabi
----------
id: 8 or "android-13"
     Name: Android 3.2
     Type: Platform
     API level: 13
     Revision: 1
     Skins: WXGA (default)
     ABIs : armeabi
----------
id: 9 or "android-14"
     Name: Android 4.0
     Type: Platform
     API level: 14
     Revision: 3
     Skins: WXGA800, HVGA, QVGA, WQVGA432, WVGA800 (default), WSVGA, WXGA720, WQVGA400, WVGA854
     ABIs : armeabi-v7a
----------
id: 10 or "android-15"
     Name: Android 4.0.3
     Type: Platform
     API level: 15
     Revision: 3
     Skins: WXGA800, HVGA, QVGA, WQVGA432, WVGA800 (default), WSVGA, WXGA720, WQVGA400, WVGA854
     ABIs : armeabi-v7a, mips, x86
----------
id: 11 or "android-16"
     Name: Android 4.1.2
     Type: Platform
     API level: 16
     Revision: 4
     Skins: WXGA800, HVGA, QVGA, WQVGA432, WVGA800 (default), WSVGA, WXGA720, WXGA800-7in, WQVGA400, WVGA854
     ABIs : armeabi-v7a, mips, x86
----------
id: 12 or "android-17"
     Name: Android 4.2.2
     Type: Platform
     API level: 17
     Revision: 2
     Skins: WXGA800, HVGA, QVGA, WQVGA432, WVGA800 (default), WSVGA, WXGA720, WXGA800-7in, WQVGA400, WVGA854
     ABIs : armeabi-v7a, mips, x86

Start AVD

Syntax:
$ emulator -avd

Example:
$ emulator -avd MyJB

It will ask for you to customize, if you are interested and you have knowledge in the options then you can go ahead with custom emulator. Press "enter" to accept default options and your emulator will start within seconds.

Install APK on emulator

Syntax:
$ adb install

Example:
$ adb install MyApp.apk

It will install the apk on your emulator.
Go to apps and click on the installed app to view the installed application.

References:

http://developer.android.com/tools/help/android.html
http://developer.android.com/tools/help/adb.html
http://docs.xamarin.com/guides/android/advanced_thttp://en.wikipedia.org/wiki/Application_binary_interfaceopics/cpu_architecture



No comments:

Featured Post

Java Introdcution

Please send your review and feedback to psrdotcom@gmail.com