Monday, November 7, 2011

Android Kitchen - Setting Up Eclipse and Android SDK

Actually following the official android setup guide should work already:
http://developer.android.com/sdk/installing.html


But we found several issues during the workshop:



1. Android SDK Path inside eclipse


Double check, make sure the Android SDK path inside eclipse is pointing to the correctly directory.



2. Use eclipse's Android manager plugin but not command line

In step 4, please use the ADT plugin to open the Android SDK and AVD Manager
From within Eclipse, select Window > Android SDK and AVD Manager.


there are problems, when not using the eclipse plugin, that even some SDK are downloaded, they cannot not be selected as Build Target inside eclipse. (We were using Indigo)



3. Always Clean and Re-build


Sometimes, an error message popup when we start the application saying "Force Close".

Very likely, it is because some generated files are cached which are not updated after changing the xml files (probably a bug in the Android plugin). For example, after changing the Android layout file (i.e. main.xml).

What you have to do is to "Project -> Clean...". This function clean up all the generated files.

If you have the "Project -> Build Automatically" option selected, Eclipse will compile all the files again. If not, click "Project -> Build Project".



4.if you use Java 1.7


We were using Java 1.7, and found out an error when we override (using @Override annotation) the onClick method of OnClickListener.

With Java 1.7, you can no longer override an interface method.

View.OnClickListener is an interface. Overriding an interface method still works in 1.6, but no longer valid in 1.7. So, "No Need to use @Override for onClick(View view) method".