Valid HTML 4.01 Transitional

HTC G1 Cellphone
Upgrade to Eclair (v2.1)

Jim Carter, 2010-04-10

Version release timeline (approximate):

I've been using the Cupcake (v1.5) distro version since about 2009-06-xx and an upgrade has been delayed outrageously long, because I have local hacks and have not been able to take the time to propagate them to the new version.

Goals

Goals for this project are:

Preparation

Prerequisites:

Java packages and their status, in OpenSuSE 11.4:

The Java Mess

For Eclair (v2.1) there was some kind of compatibility problem and Android was stuck with Java-5.0. But they seem to have dealt with their compatibility problem at least for Gingerbread (v2.3). The following notes on obtaining Java-5.0 are kept for historical reference.

Since Java is the foundation of Android, and since I don't have a lot of experience with Java, I'm going to revert to Java-1_5_0. Here is a discussion of what @Override is good for. It isn't too clear what Android's problem is -- in Java-1_6_0, @Override was extended to mark interface implementations but as I understand it, that is not mandatory.

Obtaining Java-1_5_0: I'll need java-1_5_0-sun, java-1_5_0-sun-plugin, java-1_5_0-openjdk, and probably java-1_5_0-openjdk-devel and java-1_5_0-openjdk-plugin. Not available from SuSE build service. Not available on Packman. The URL with java-1_6_0-sun is https://jdk-distros.dev.java.net/developer.html. This is the website of the OpenJDK project. From this site you can download versions 6 and 7, but apparently version 5 is deprecated and is not available.

Another change of plans: the main Makefile does java -version and javac -version and wants to see 1.5 in the output. So where do other people get version 1.5? Here's a thread on how to get Java 1.5 (by nictam, dated 2009-12-01). To summarize (combining nictam's instructions and jimc's notes on the procedure):

Get and Build the Source

For instructions to obtain the latest Android sources, see http://source.android.com/download. Update, on or before 2010-11-20 this link is broken. Start at http://source.android.com/, follow the link to source, follow the link to Getting the Source. In summary:

See a list of phones and OS versions by count of accesses to the Android Market.

Version 2010-04-12 2010-11-01
2.2 Froyo -- 36.2%
2.1 Eclair 27% 40.8%
1.6 Donut 32% 15.0%
1.5 Cupcake 38% 7.9%
Older Versions 3% 0.1%

Getting the SDK

The SDK is specific or closely related to the particular Android version. The sources include a toplevel directory called sdk; however, I think this is glue code, and the real SDK is found in ../android-sdk-linux_86 . In addition to the SDK framework, you need to install the platform for your Android version. API 7 is for Eclair; API 8 is for Froyo; API 9 is for Gingerbread.

I'm perusing android-sdk-linux_86/SDK_Readme.txt, It says that this archive only contains tools, not an Android platform. Execute $HOME/android/android-sdk-linux_86/tools/android and use the GUI to download a platform, or they also give a command line. It starts out with no Android Virtual Devices, and one Installed Package: Android SDK Tools v5. Available packages: gives a URL to Google's repo, Click on the triangle to download the package list. Relevant item(s) seem to be: Example shows Android 2.1 Eclair, and ths implies API v7 (change to the latest version.) Probably I am just wasting bandwidth to download all of the following, but this is what I selected:

See this link for downloading the SDK. They say, if you already have an old version, use the Android SDK and AVD Manager to upgrade, rather than downloading the whole thing afresh.

The downloaded documentation is a copy (not particularly recent) of what is rooted at http://developer.android.com/. Google suggests that you use the online version because it has a server-based search feature and is more up-to-date.

It does not create an AVD (Android Virtual Device) automatically. This task is described in docs/guide/developing/tools/avd.html . The AVD is a symbolic structure with these components:

Using the $HOME/android/android-sdk-linux_86/tools/android program, select Virtual Devices - New. In the dialog specify:

The device's name

Likely you will end up with several AVDs, so pick recognizable names.

Target

For me, Android-2.3.3 (API 10)

SD card

If you specify the size it will create the file for you; or you can give your own filename, which I believe could be the raw device for an actual SD card in your card slot. I'm using 64Mb.

Skin

Mainly you're giving the screen size in pixels. The G1 is 480x320px which is referred to as HVGA. The Nokia 770 series is designated as WVGA800 meaning 800x480px. Or you can specify the size explicitly.

Hardware

Abstract LCD Density is preset to 160 (dots per inch?) Hit New and you get a dialog with a dropdown box from which you can select a hardware feature that you want. For emulating the G1 I selected SD-card, keyboard, trackball, touchscreen, audio playback, battery, and 128Mb RAM (default is 96Mb). Features actually on the G1 that I omitted, having trouble to provide them to tne emulator, were accelerometer, GPS, camera, audio recording, and GSM (cellphone) modem. Also my phone does not use a cache partition, and I left the VM heap size unset. The G1 has no arrow keys.

So the AVD was successfully created. Select the AVD and hit Details to see its properties, specifically its filename, which is $HOME/.android/avd/$NAME . Hit Start and it will boot up. Allow plenty of time; it takes long enough on real hardware and longer on the emulator.

Before launching it will give you Launch Options. The default screen size is 3in, and I selected scale display and changed this to 6in.

Points about the emulated experience:

Adding Software

Next step: Building and including the components that I want. See the Goals section for a list.

I think we want to create a custom device that inherits from ./device/htc/dream/*.mk . Use a goal of PRODUCT-${productname}-${variant} where $productname is the device and $variant can be one of user userdebug eng tests , defined in product_config.mk variable INTERNAL_VALID_VARIANTS .

Several Android.mk files suppress compilation if the target is the simulator. Including dropbear, ipsec-tools, e2fsprogs, ping, strace, i.e. all the programs I want in the external directory, but never in packages/apps. Also e2fsprogs only builds if the target is x86. These makefiles will have to be hacked.

See this tutorial about git. We've already done git checkout -b froyo, so I don't actually need to do anything, just hack the sources. List of hacks:

Gingerbread (Android-2.3) does not support the HTC Dream (hiss, boo!) For the Target Object I copied the work I did for Froyo, including these files (inherited products):

Weasels! Apparently, starting in Android-2.0 Donut they stopped including the kernel sources and they rely on a vendor-supplied proprietary kernel. Now what? . . . Continued on the CyanogenMod page.

Getting Eclipse to Work

Getting Eclipse to work. My version is Eclpse-3.4 Ganymede. It appears that you need to explicitly install eclipse-jdt, eclipse-platform, eclipse-archdep-platform, libswt3-gtk2. These will drag in additional dependencies but will not be dragged in themselves. The symptom of a lack of libswt3-gtk2 is that Eclipse reports an error and refers to a log file which it has deposited in ~/.eclipse/org.eclipse.platform_3.4.0_1543616141/configuration/ This file is named with the time of Eclipse execution in seconds after the UNIX epoch, extended with 3 fractional digits (milliseconds). It appears to be complaining that it can't find the class org.eclipse.swt.SWTError, which is no lie because libswt3-gtk2 is absent.

Also see: Installing the Android Plugin for Eclipse by Artem Russakovskii Android Police.

Next step: How to Use Eclipse (and how to set it up for Android).

Following along in sdk/index.html , step 2, put the SDK (and Java-1.5) on the path and start up Eclipse.

Step 2A: Executing as root, so you have write permission in the relevant directories, start Eclipse. Hit Help - Software Updates - Installed Software (should be the initially selected tab). Select Eclipse Platform, and hit Update.

Step 3, set up a remote update site https://dl-ssl.google.com/android/eclipse/ . Detailed instructions for how to do this are at sdk/eclipse-adt.html . Summarizing:

So how am I going to deal with the permission problem? Plan A: Install my own private copy of Eclipse. Plan B: do the installation as root. Plan C: give the user permission to write on the distro's files. I'll start with plan C.

The official system image and kernel are found in android-sdk-linux_86/platforms/android-7/images . Presumably these can be overridden with hacked versions.

They recommend that you go through the Hello World tutorial, resources/tutorials/hello-world.html . Doing it:

Left off at: Execute in the emulator.