Using the Emulator
Before we start this tutorial, make sure that you have install Android SDK for Eclipse. For more details please see this tutorial Install Android SDK
Create an Android Emulator Device
The Android tools include an emulator. The emulator behaves like a real Android device in most cases and allows you to test your application without having a real device. You can emulate one or several devices with different configurations. Each configuration is defined via an "Android Virtual Device" (AVD).
To define an AVD open the "AVD Manager" via→ and press "New".
Enter the following.
We can also select the box "Enabled" for Snapshots. This will make the second start of the virtual device much faster.
At the end press the button "Create AVD".This will create the device and display it under the "Virtual devices". To test if your setup is correct, select your device and press "Start".
After (a long time) your device should be started.
Obviously you can use the emulator via the keyboard on the right side of the emulator. But there are also some nice shortcuts which are useful.
Alt+Enter maximizes the emulator. Nice for demos.
Ctrl+F11 changes the orientation of the emulator.
F8 turns network on / off.
Try to use a smaller resolution for your emulator as for example HVGA. The emulator gets slower the more pixels its needs to render as it is using software rendering.
Also if you have sufficient memory on your computer, add at least 1 GB of memory to your emulator. This is the value "Device ram size" during the creation of the AVD.
Also set the flag "Enabled" for Snapshots. This will save the state of the emulator and let it start much faster.
Things are not always working as they should. This section gives an overview over typical problems and how to solve them.
Several users report that get the following errors:
Project ... is missing required source folder: 'gen'
The project could not be built until build path errors are resolved.
Unable to open class file R.java.
To solve any of these errors, go to the project menu and select Project -> Clean.
The communication with the emulator or your Android device might have problems. This communication is handled by the Android Debug Bridge (adb).
Eclipse allows to reset the adb in case this causes problems. Select therefore the DDMS perspective via→ → →
To restart the adb, select the "Reset adb" in the Device
View shows you the log messages of your Android device and help you analyze problems. For example Java exceptions in your program would be shown here. To open this view, select → → → → .
If your emulator does not start, make sure that the android-sdk version is in a path without any spaces in the path name.
The @override annotation was introduced in Java 1.6. If you receive an error message for
@override, change the Java compiler level to Java 1.6. To do this right-click on the project, select → → and select "1.6" in the drop-down box.
Java requires that classes which are not part of the standard Java Language be either fully qualified or declared via imports.
If you see error message with "XX cannot be resolved to a variable", right-click in your
Editor and select → to important required packages.