I just came up with this quip – so I figured I would write it down.
SI543 – Beginning Java for Google Android
I have packaged up the lectures, podcasts, assignments, blog entries, etc about the emergent use of Google Android in SI543 at University of Michigan.
Go here for an intro to using Google Android
www.si543.com/si543/ – soon this will just be www.si543.com.
Important Google Android Skill – My Applications don’t seem to get updated!
If you keep making modifications and they are *not* making it down to your Android device you can wipe out the versions of the app on our device as follows. For example – I simply added a Log.i method to the onCreate method and it *never* came out – I thought I was crazy. I figured I was doing something wrong.
I don’t know why it does not just overwrite the files on my Emulator – but by blasting the files on the emulator life gets much better.
Start this process with Eclipse up and running and the emulator up and running – hey try to update your app.
$ cd /Users/csev/dev/android_sdk_darwin_m3-rc20a/tools $ ./adb devices List of devices attached 1 emulator-tcp-5555 device 0 $ ./adb shell # ls drwxr-xr-x root root 1969-12-31 19:00 var drwxrwxrwt root root 2007-12-01 08:06 tmp drwxr-xr-x root root 2007-11-11 15:59 system drwxr-xr-x root root 1969-12-31 19:00 sys drwxr-xr-x root root 1969-12-31 19:00 sbin dr-xr-xr-x root root 1969-12-31 19:00 proc -rwxr-xr-x root root 93824 1969-12-31 19:00 init drwxr-xr-x root root 1969-12-31 19:00 etc drwxrwx--x system system 2007-11-11 15:59 data drwx------ root root 1969-12-31 19:00 root drwxr-xr-x root root 2007-12-01 08:06 dev # cd data # cd app # ls -rw-rw-rw- root root 139313 2007-12-01 08:06 Lunar.apk -rw-r--r-- system system 1325833 2007-11-11 15:59 ApiDemos.apk -rw-rw-rw- root root 139233 2007-11-13 16:50 Toozday.apk -rw-rw-rw- root root 49781 2007-11-29 08:01 Twitter.apk -rw-rw-rw- root root 51506 2007-11-29 12:21 Hello.apk -rw-rw-rw- root root 11931 2007-11-29 12:32 H2.apk -rw-rw-rw- root root 54804 2007-11-29 18:48 SkeletonActivity.apk -rw-rw-rw- root root 11931 2007-11-29 19:49 H3.apk -rw-rw-rw- root root 139591 2007-11-30 20:07 LunarLander.apk # rm Too* # rm Hello* # rm H2* # rm H3* # rm Ske* # rm L* # rm T* # ls -rw-r--r-- system system 1325833 2007-11-11 15:59 ApiDemos.apk # (Exit with CTRL-D)
Then run the app again – Voila!
SO far once I have done this – I can re-download again the normal way – if I get stuck and downloads seem not to be overwriting the app on the emulator – blast away!
Google Android Notes
Just some notes.
(1) If you see the text
ActivityManager: Error: Activity class {org.chuck/org.chuck.Hello} does not exist.
When you recompile – you are doomed. You can find some stuff in the
Android Beginner Groups but all you will learn is that no one knows the answer to this. The solution is to start a new project and paste your code into that new project.
(2) Do not use the XML editor built into Eclipse to add attributes – it seems incapable of editing XML except when you change attributes. Just use some other editor like vi or notepad to edit the XML. Then use right-click on the XML file and “Refresh” in Eclipse to get Eclipse to re-read it and re-generate the R.java file and compile the rest of your app. You *can* change attribute values – just not add new attributes. What I really need to do is tell Eclipse to just open the dang file without their little helper so you can edit the XML directly.
(3) Do not shutdown and restart the emulator – you should only start the emulator once per Eclipse session. If you shut it down, Eclipse will start it back up – but something will be subtly wrong. No big deal if you close the emulator. Just close and restart Eclipse.
(4) The Log.i is the best way to get debugging output. System.out.println should go to the log – grrr. AH well – just use the log.
(5) The Mac stuff is Intel-only.
Outstanding issues
(1) I do not know how to completely reset the emulator – I would like to have it not sure the programs are 100% gone between downloads – it makes me nervous – but it is not fatal.
That is all for now. I am off and running to write a Pong game based on a hack of the Lunar Lander. I have Twitter and reading and parsing RSS in Android working – it needs a completely new UI – but the networking is working and the XML parsing is working – so I am satisfied for now. That tool will be evolved into that IMS Tool interoperability for the Android – but I really want the last SI543 assignment to be a pong assignment to match our pong assignment in regular Java. So I will work on Android Pong before Android IMS Tool Interoperability.
Google Android Twitter Viewer
Well – I have a simple Google Android application that read an RSS feed and parses out the title of the first item and displays it.
The cool thing is that my XML map parser works in Android too! Pretty printing broke so I will have to rewrite that bit.
Now I need to write a pong game in Android and then IMS Tool Interoperability in Android.
I think that I just taught the first lecture in a for-credit college course (SI 543 at University of Michigan) that is about Google Android!! It is recorded – when it goes up I will post a URL. The first Android homework is already complete by a number of the students in the course in tonight’s lab based on the
Dr. Chuck – Going to Newport Beach
I am going to Newport beach after all – I will arrive Friday evening and leave Monday evening so I can be back to teach Tuesday. So I will go to the project coordination meeting mostly. See you there.
Nifty C-Shell foreach script Trick for spaces with file names
This code did not work with files with spaces in the name:
foreach i ( `find . -name '*.java'` ) ls -l "$i"
This code did work:
foreach ii ( `find . -name '*.java' | sed 's/ /@@@@/g'` ) set i=`echo $ii | sed 's/@@@@/ /g'` ls -l "$i"
I was quite pleased – I almost resorted to using walk in Python – but that was averted. Somehow Sakai’s assignments tool (in mid semester) changed the format of the “Download all for grading” ZIP file. I am sure it is an improvement – but it broke my C-Shell scripts I use for grading.
Plaxo started working on Leopard!
I do not know what I did – but Plaxo *just* started working on my Mac OS 10.5 Leopard box. Now I need to sync all the way to my iPhone… That would be awesome to have it working again.
Playing With Python – Notes
Just some notes – I am trying to build a python script to fix the dates on my files. I mistakenly use cp instead of tar to restore my home directory during my upgrade to Leopard. So now I have to go through and patch all of the files modification times from the backup.
It should be a fun exercise in Python. Notes below
Cleaning up my Desktop – Sweet Ruby Code for Meeting Maker to VCard
I wrote some Ruby code to convert from Meeting Maker to iCal’s VCARD format. Then I sent it to Trek Glowaki and he rewrote it.
Here is my
Original Version. Trek’s much cleaner version is below – it shows some pretty Ruby idioms.