Sunday, February 28, 2016

7. Tutorial: Create and run Android Virtual Device
To define an Android Virtual Device (ADV) open the "AVD Manager" via Windows → AVD Manager and press "New".
Create a new AVD
Enter the following.
Settings for a new AVD
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 AVD configuration 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 AVD starts. You are able to use it via the mouse and via the virtual keyboard of the emulator.
8. Error handling and typical problems
Things are not always working as they should. This section gives an overview over typical problems and how to solve them.
8.1. Clean Project
Several users report that get the following errors:
  1. Project ... is missing required source folder: 'gen'
  2. The project could not be built until build path errors are resolved.
  3. Unable to open class file R.java.
To solve any of these errors, go to the project menu and select Project → Clean.
8.2. Problems with Android Debug Bridge (adb)
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 Window → Open Perspective → Other → DDMS
To restart the adb, select the "Reset adb" in the Device View.
http://www.vogella.de/articles/Android/images/xadbreset.png.pagespeed.ic.nII1-qWW1d.png
8.3. LogCat
The "LogCat" 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 Window → Show View → Other → Android → LogCat.
8.4. Emulator does not start
If your emulator does not start, make sure that the android-sdk version is in a path without any spaces in the path name.
8.5. Timeout during deployment
If you face timeout issues during deployment you can increase the default timeout in the Eclipse preferences. Select Window → Preferences → Android → DDMS and increase the "ADB connection timeout (in ms)" value.
8.6. Install failed due to insufficient storage
Sometimes the emulator will refuse to install an application with the error message: INSTALL_FAILED_INSUFFICIENT_STORAGE.
An Android virtual device provides per default only 64M for the storaging Android applications. You can clean your installed application by re-starting the emulator and selecting the "Wipe user data" flag.
Alternative you can set the the data partition size, if you press edit on the AVD you can set the "Ideal size of data partition" property via the "New" button.
Setting the Ideal size of data partition for the ADV
8.7. Debug Certificate expired
If you get the error message "Debug Certificate expired" switch to the folder which contains the Android AVD, e.g. ".android" under Linux and delete the "debug.keystore" file. This file is only valid for a year and if not present Eclipse will regenerate the password.
8.8. Error message for @override
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 Properties → Java Compiler → Compiler compliance level and select "1.6" in the drop-down box.
8.9. Missing Imports
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 Source → Organize Imports to important required packages.
8.10. Eclipse Tips
To work more efficiently with Eclipse, select Window → Preferences → Java → Editor → Save Actions and select that the source code should be formatted and that the imports should be organized at every save

No comments:

Post a Comment