Apps | Hardware | Setup | Network | Hacking | Wishlist | Top |
Eclair(v2.1)
Version release timeline (approximate):
Cupcake(v1.5) released; I hacked and installed it.
Donut(version 1.6) released.
Eclair(version 2.0 and 2.1) for quite a number of new phones.
Froyo(version 2.2)
Gingerbread(version 2.3)
Honeycomb(version 2.4) is shipping on a number of tablet machines, but is not released as open source.
Honeycombopen source release is promised in Fall.
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 for this project are:
Upgrade everything, with the latest features and bugfixes. Features to be looked for include:
Retain existing hacks, specifically:
Add developer packages not in the normal image, specifically:
Add software not in the Android distro, specifically:
Make progress on running Debian on the phone. The existing backup procedure is not really satisfactory, and there are other hacks I want to do that require a normal UNIX environment.
Install a custom kernel minus the paranoid network
feature
and with IPv6 support -- my home net uses IPv6. This is required for
the things I want to do in Debian.
Learn to use the development environment;
Prerequisites:
Java packages and their status, in OpenSuSE 11.4:
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):
Obtain JDK 5.0 Update 22 from
Oracle's Previous Release
page (registration required for
download).
They mail you a message with a link in it to another web page, which (after you tell it your architecture) has a link to the actual file. There are two variants, jdk-1_5_0_22-linux-i586.bin and jdk-1_5_0_22-linux-i586-rpm.bin ; since I'm installing this in userspace I got the non-RPM version. File size: 49.7Mb. It will expand to 139Mb.
The result is a shell script with a tail of compressed material.
You're supposed to execute it. It shows you the license (using more
,
hiss, boo, press space to proceed, you can't back up) and you have
to agree. In the current directory it makes a subdir jdk1.5.0_22 and
the payload is within that.
In jdk1.5.0_22/bin you will find the java and javac commands. Make sure this bin directory is on the path ahead of /usr/bin which is the usual location for java and javac. With my directory structure, illustrating both csh and sh syntax, you would use this command line:
csh: (set path = (/home/jimc/android/sun-java/jdk1.5.0_22/bin $path) ; make)Nictam reports that he was able to build Android with no problems using this technique. See later for an improved make procedure.
sh: PATH=/home/jimc/android/sun-java/jdk1.5.0_22/bin:$PATH make
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:
Install the prerequisites (see above). [Done]
Make a directory to contain the sources. This will be ~jimc/android/android-2.3 owned by jimc:maint mode 755. The corresponding directory for v1.5 will be kept until hacks have been transferred over. [Done]
Download their repo
script. I'm going to re-download it
for each new version for paranoia's sake. Actually, the
repo sync
step does this download automatically but it's
probably better to to it ahead of time.
cd
to the source directory and use repo to obtain the current
manifest. The first time you download any sources it will want your
full name (for attribution if you submit patches) and Google developer
email address. I'll give my gmail account. Command line (where
$branch = cupcake
, gingerbread
, etc:
repo init -u git://android.git.kernel.org/platform/manifest.git -b $branch
You only need to do this the first time; if you come back to the
project after several months, just do repo sync
.
Execute repo sync
to download the files in the manifest.
Verify signatures.
The instructions include a public key (ID 9AB10E78) and instructions how to install it on your GPG keyring.
Assuming you actually trust that no hackers have replaced this
public key with their own, or compromised the corresponding secret key,
or inserted a Trojan horse into the Android sources before they
were signed, use
seahorse
(GUI) or gpg
(command line interface) to sign
this key. (Actually the main threat is that the data gets corrupted
in transit or some files are missing, and presumably this would be
revealed when a signature check fails.)
Some projects [in Cupcake] have a directory $project/refs/tags which is
not empty and contains a number of files named after Android
releases, e.g. android-2.1_r2 . Each one contains the SHA1 checksum
of a git object, almost always a commit object. cd $project
and do git tag -v android-2.1_r2
(or whatever tagname).
Git will report the object's identity and whether the signature is
good, i.e. whether the object that you downloaded is identical to
the one that was signed.
Look for .repo/projects/$various/refs/tags (where $various
could have multiple levels). But in Android-2.2 they are all empty.
However, .repo/manifests.git/refs/tags contains content: files named
after Android and SDK version numbers. Each has a 160-bit sum.
It's not obvious what it's a sum of. But you can check
this sum using this command line (where $tagname is one of the file
basenames in the tags directory, e.g. android-2.2_r1.3):
cd .repo/manifests.git
git tag -v $tagname
.repo/repo/.git/refs/tags also has content. This may or may not refer to the repo script itself. There is no tag named after the version of the script itself.
I don't know enough about git to know just what the commit
object is, that is, whether an alteration to the source code would be
noticed when the signature is verified. I checked out the default
branch, which is called master
, but I'm not able to determine
which of the Android releases this is. All signatures that were
checked were accepted.
Gakk, starting in version 2.3 (Gingerbread), they no longer support 32-bit build environments. I'm going to have to install the x86_64 OS version in a dual boot configuration. (Update: ended up making x86_64 the production architecture.)
Now build the sources. Warning, when you do make
in the
toplevel directory with no explicit target, it does the equivalent of
make clean
first. Apparently we have version 2.1-update1, ARM
target, x86 host. The Get Source
document recommends exporting
these variables.
For using Java-1.5.0, I have a symlink called sun-java in the Android source root dir to the Sun Java package root; if your sun-java directory is elsewhere, fill in the actual directory.
export JAVAHOME=$PWD/sun-java
export PATH=$JAVAHOME/bin:$PATH
make [$target]
For using the distro's Java: you're looking for the SDK. Android apparently prefers openjdk; the alternative is Sun Java. You can export JAVAHOME=/usr/lib64/jvm/java which should ba a symlink to /etc/alternatives/java_sdk which in my case points back to /usr/lib64/jvm/java-1.6.0-openjdk . Alternatively you can export JAVAHOME=/usr/lib64/jvm/java-sun pointing to /etc/alternatives/java_sdk_sun which points back to /usr/lib64/jvm/java-1.6.0-sun .
The build was not entirely free of warnings but most of what I saw were nitpicks, e.g. use of a deprecated API, or failure to follow documentation standards. The Java compiler used both cores of a dual-core machine, and the process is CPU limited. On a Intel Core 2 Duo P7450 @ 2.13GHz the build took 119 minutes. Result files (sizes shown for Froyo, only a liitle expanded from Cupcake):
Interesting tidbits in the install files:
goldfish(not sure if this is the G1 or a version for the emulator).
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% |
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.
Available Packages. You should have a site https://dl-ssl.google.com/android/repository/repository.xml . In tools version 12 it just says
Android Repository, but that's the URL it eventually uses. If missing, add it.
Install Selected. When it finishes downloading and installing, it offers to restart, then recommends that you exit and restart manually. Do that, and start from the beginning.
Installed Packages.
Update Allto get bugfixes for installed old versions (if any).
Available Packages. Again hit the open triangle for
Android Repository.
Install Selected. Check and agree to the licenses. It will replace the old version of the Android SDK Tools. It downloads and installs the packages. For me it took 40 minutes on a 768 Kbit/sec DSL line, estimated 240Mbytes compressed, 550Mb uncompressed.
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:
Likely you will end up with several AVDs, so pick recognizable names.
For me, Android-2.3.3 (API 10)
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.
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.
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:
Without scaling the display it displays pixel for pixel, and on a laptop screen it's hard to read. Much better to scale the display 2x. It is anti-aliased on the host display's pixel grid, not the emulated display's grid of double size pixels; I wonder how they do that.
The display is in portrait orientation; I haven't figured out how to switch to landscape.
You get a collection of buttons which probably are the union of all the buttons on all known phones. Buttons for declined hardware (in my case the camera and arrow keys) are unresponsive. You also get a picture of a QWERTY keyboard, which functions.
If you send keystrokes to X-Windows when the emulator has focus (i.e. type on the laptop's keyboard), they are sent to the emulated machine. If you send mouse events within the screen, they are interpreted as taps on the touchscreen. Scroll events have the appropriate interpretation.
The status bar alleges that you have a 3G connection, which is actually bridged to your laptop's packet bus. The emulated phone can do network activities in the normal way. The traffic originates from the host; as seen from the host the emulated phone does not have any bridging interface nor does it have its own IP address.
To shut off the emulator, hold down the End (red) button, that is,
get the mouse cursor over the End button and hold down the host's
Button-1. The virtual machine
will do the normal shutdown procedure, i.e. pop the dialog and
confirmation boxes, in which you click. But it will sit showing
shutting down
for a long time. I gave it about 5 minutes,
then closed the window using the host's window manager facility,
which led to killing the emulator.
In the future I will give it about 15 seconds, same as on the real
hardware.
Now what kernel and system image was it using? And how can I make it use mine?
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. 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).
Make the sources. Already done.
Bloat up Eclipse's memory even more than it already is because Android sometimes runs it out of memory. As root, edit /usr/share/eclipse/eclipse.ini changing -Xms (heap minimum size) to 128m from 40m, and -Xmx (maximum heap size) to 512m from 256m.
Start Eclipse (eclipse
on command line, or use desktop
menu or icon). See the above page for the steps to direct it to the
Android source files.
[Cupcake:] I got an error message: build path contains duplicate entry:
'frameworks/base/vpn/java' . Hit Next
, it gives you a combo
box with tabs for Source, Projects, Libraries, and Order. Click on the
latter. Find the duplicate entries. Uncheck the checkbox (a hyphen
represents a checked box) on one of the duplicate entries. It does
several steps labelled "removing project", then rebuilds the project,
still with an error. The problem is in the provided .classpath file,
which you are supposed to copy into the distro root. Outside of Eclipse,
edit it to not have the two instances of frameworks/base/vpn/java.
There's another duplicate,
out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/vpn/java .
Get rid of that also.
[Froyo:] It complained that the build path lacks the required
libraries out/target/common/obj/JAVA_LIBRARIES/{ google-common_intermediates , gsf-client_intermediates }/javalib.jar .
These are library entries in .classpath. I commented them out using
SGML comments: <!-- entry -->. That done, it seems to have built
successfully (this is the Eclipse build, not the real
build).
Once the build path is cleaned up, then it will start building,
which takes about a minute, assuming make
has already been run.
0 errors, 8999 warnings, 0 other messages. I don't know how to display
the complete error message, but the first few have all been about
various classes being raw types.
Now I want to run the project. Hit Run, select Run, it asks whether to run it as a Java Applet, Java Application, or JUnit Test. None of these seem appropriate.
The how to use Eclipse
doc gives a procedure to start the
emulator. You must be running Bourne shell for the environment
setup to happen. However, use the procedure shown later to configure
and start it -- the default AVD (Android Virtual Device) is not too nice.
/bin/bash
export SHELL=/bin/bash
. build/envsetup.sh
lunch 1 #lunch is a function in envsetup.sh, arg is one
make #You were supposed to have already done this. Takes 1.5 hours.
emulator #See below for more about the emulator.
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:
Developer Toolsand hit Install. (This includes
Android DDMSand
Android Development Tools.)
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.
chgrp -R maint /usr/share/eclipse ; chmod -R g+w /usr/share/eclipse
(My identity is a member of group maint. You could use a group
that you are a member of, or create one for the purpose, or change
the ownership to yourself.)
Repeated the last step above, downloading WDT and EEJ, executing as the user.
Not so fast. It had switched to root's workspace. Switched back. The Android site vanished (present only in root workspace?) Added it again.
Expanded http://dl.google.com/eclipse/plugin/3.4 , selected
Something prints out This time I get an installation confirmation box, 26Mb download.
Evidently it thinks it can resolve deendencies now. Hit Next.
Read and agree to the license. Hit Finish. Download begins;
Eclipse components which were previously missing are shown as incoming
in the progress box. When the download finishes, accept its offer
to restart Eclipse.
So that seems to have been successful. Now, what do I do with it?
Duh, finish the configuration. Following along in
sdk/eclipse-adt.html : Google Plugin for Eclipse 3.4, hit Install.
[Fatal Error] :1655:523: Premature end of
file.
But it doesn't seem to be fatal.
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:
Install a platform. I have Android-7 installed.
Create an AVD. My AVD is created and works.
Create a new Android project. Evidently my ADT installation is not finished, because the promised Android Project template is not visible. Neither is the Android run-configuration present.
Left off at: Execute in the emulator.
Apps | Hardware | Setup | Network | Hacking | Wishlist | Top |