Monday, May 30, 2011

Andriod Emulator - Trouble shooting

Problem:

When I use MapActivity, I can see grid of the map and zoom controls. But I cannot see the map.

Causes:
1. You have not set up mapkey in xml file properly. Check this to find out how.
or
2. Your map does not have a default location to show. Set up default location as follows:
On windows command line, type
telnet localhost 5554
geo fix -120.62 35.29
This will set a location for map to show.

or
3. You do not have internet connection




I cleaned up build and I cannot find R.java anymore

Causes:
There should be some error in one of the xml files. Correct it. Once xml files are correct, building project  will create R.java automatically.

How can I find logcat on Android emulator 
Open DDMS by
Go to windows > Open Perspective > DDMS

Then open logcat by
Window > Show view > logcat

Emulator is taking the whole screen. How can I resize emulator

Go to Window> Android SDK and AVD Manager
Select emulator and click on edit.
Enter width and height at Resolution fields under Skin to set new resolution.



Friday, May 27, 2011

Android error: error: Error: No resource found that matches the given name (at 'drawable' with value '@drawable/....').

I have been getting this error and I could not figure out what is the problem. Finally figured out the reason.

This error means that R.java does not have a reference to the image file in question.
Check R.java under gen folder and find out  if it has a location reference to the image file you added.  If it does not, these are the possible reasons.

1. You forgot to add image file to res drawable folder
2. You added image file to a wrong drawable folder. There are three drawable directories, namely
drawable-hdpi, drawable-ldpi, drawable-mdpi. Try to add image to all three directories and one of them will work depending on the resolution size of your image.


3.  You have another file in the folder with the same name. Rename one of them so that there are no name conflicts.