Monday, May 13, 2013

How to install/run Android emulator on Ubuntu or Debian

Here is guide on how to run Android emulator on Ubuntu or Debian.

Android emulator comes with Android SDK, and therefore you need to install Android SDK. Follow the steps below to install Android SDK on Linux.

0532918ac6054700b72f749308d7ea88.png

Android SDK requires Java JDK. Therefore install Java JDK first.

To install Java JDK on Ubuntu or Debian:

sudo apt-get install openjdk-7-jdk

To install Java JDK on CentOS, Fedora or RHEL, first set up Repoforge repository on your system, and then run the following.

sudo yum install java-1.7.0-openjdk-devel

Now download Android SDK ADT bundle from Android official site. Unzip the downloaded ADT bundle, and copy the sdk directory to your preferred location. Here I assume that the installation directory of Android SDK is ~/android-sdks.

For 64-bit Linux user: you must install another prerequisite called ia32-libs since Android emulator is 32-bit software. The ia32-libs package contains a set of runtime libraries for the ia32/i386 architecture, configured for use on a 64-bit kernel. On 64-bit Linux, the mksdcard utility which creates SD cards will fail without this package.

sudo apt-get install ia32-libs

While using ia32-libs, if you encounter any error with 32-bit libGL.so, do the following:

sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1.2.0 /usr/lib/libGL.so

In order to run Android emulator, you first need to create a new AVD (Android Virtual Device) which is an emulator configuration for the Android device to be emulated. To create a new AVD, first launch Android SDK Manager by running the following.

~/android-sdks/tools/android

Go to “Tools” > “Manage AVDs” on Android SDK Manager’s menu. It will open up AVD Manager.

Click on “Add” button to create a new AVD. An example configuration of a new AVD is shown below.

2f2df1f603100e84f158bac2ecb60248.png

If an AVD has been successfully created, you will see the following confirmation.

3abaff72f0aed01c02dff9563f8cdf28.png

You can check the list of available AVDs as follows.

~/android-sdk/android list avds Available Android Virtual Devices: Name: my_avd Path: /home/xmodulo/.android/avd/my_avd.avd Target: Android 4.2 (API level 17) ABI: armeabi-v7a Skin: 800x1280 Sdcard: 1G

To launch Android emulator with the AVD that you have created, highlight the AVD on AVD Manager, and click on “Start” button on the right sidebar.

f48247b46c967d7a0ca38b6abf49aed7.png

Alternatively, you can start Android emulator directly from command line as follows. In this case, specify “@[your_avd_name]” as an argument to the emulator.

emulator @my_avd

Booting up Android emulator may be slow (even taking minutes) depending on your hardware. Once Android emulator is successfully launched, you will see an running instance of Android device.

a110cde9fb2656afc5f43c936c9af5da.png

Have a Happy Droiding!

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐