This section on Android exceptions explains the exceptions and the work around for android exception that occur in android application development Android system creates some problems or errors and here we are discussing how to handle these errors. These are the type errors generated by an android system and define how to handle these errors.
- Clean Project
- Problems with Android Debug Bridge (adb)
- Emulator does not start
- Timeout during deployment
- Install failed due to insufficient storage
- Debug Certificate expired
- Error message for @override
- Missing Imports
- Eclipse Tips
1) Clean Project
An android system generates the following errors.
a) Project … is missing required source folder: ‘gen’
b) The project could not be built until build path errors are resolved.
c) Unable to open class file R.java.
In order to solve the above errors we are using clean project operation. Here we are selecting the project menu and after that we select Project→ Clean.
2) Problems with Android Debug Bridge (adb)
Android system generates communication error. This error generated at the time of communication between emulator and our android device.
Eclipse allows resetting 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.
The LogCat view helps to display the log messages of our android device and also it helps to analyze the problems.
Eg: – Java exception of our program will display here.
To open this view, select Window → Show View → Other → Android → LogCat.
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.
5) Timeout during deployment
For solving the timeout issues during deployment we can increase the default timeout in the eclipse. These are the steps to set the default timeout.
Select Window → Preferences → Android → DDMS and increase the “ADB connection timeout (in ms)” value.
6) Install failed due to insufficient storage
Sometime the android shows an installation error message or the emulator will refuse to install an application. At this time it shows the below error message.
By default the AVD gives only 64M for storing the android applications. By solving installation error we are using two methods
1) Clean our installed application by restarting the emulator and selecting the “Wipe user data” flag.
2) Set the data partition size, if we press edit on the AVD we can set the “Ideal size of data partition” property through the “New” button.
7) Debug Certificate expired
If you switch to the folder which consists of the android AVD we get an error message like “Debug Certificate expired”.
Eg: – “.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) Error message for @override
This error is a type of annotation error. If this error happens for @override we change the Java compiler level to Java 1.6. These are the steps to handle this type of error.
Right-click on the project, select Properties → Java Compiler → Compiler compliance level and select “1.6” in the drop-down box.
9) Missing Imports
Java required the classes which are either fully qualified or declared through imports. Missing of fully qualified or declaration leads to an error message. The error message is shown like this “XX cannot be resolved to a variable”. For solving this problem, right-click in our Editor and select Source → Organize Imports to important required packages.
10) Eclipse Tips
For creating the efficient Eclipse choose 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.
Hope the above tips on the android exception will provide an insight on solving the exceptions that you encounter during android application development.