androidをビルトしてみる

# apt-get install git-core gnupg sun-java5-jdk flex bison gperf \
                  libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential \
                  zip curl libncurses5-dev zlib1g-dev 
注意、'libsdl-dev' の代わりに 'libsdl1.2-dev' を選択しています
E: パッケージ sun-java5-jdk が見つかりません

// sun-java-5-jdk は sun-java6-jdk になったがこれをインストールするにはレポジトリ追加をしないといけない 
// これからは openjdk-6-jdk らしい
# aptitude install openjdk-6-jdk


$ curl http://android.git.kernel.org/repo >~/bin/repo
$ chmod a+x ~/bin/repo
$ repo init -u git://android.git.kernel.org/platform/manifest.git
$ repo sync
... DL5GBくらい。timeコマンド付けて実行すればよかった・・・

$ make
============================================
PLATFORM_VERSION_CODENAME=AOSP
PLATFORM_VERSION=AOSP
TARGET_PRODUCT=generic
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=OPENMASTER
============================================
Checking build tools versions...
build/core/main.mk:72: ************************************************************
build/core/main.mk:73: You are attempting to build on a 32-bit system.
build/core/main.mk:74: Only 64-bit build environments are supported beyond froyo/2.2.
build/core/main.mk:75: ************************************************************
build/core/main.mk:76: *** stop.  中止.

なん・・・だと・・・

仕方ないので Eclair (2.1) のブランチに切り替える
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b eclair
$ repo sync

$ make -j2
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.1-update1
TARGET_PRODUCT=generic
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=ECLAIR
============================================
*** A clean build is required because of a recent change.
*** Done with the cleaning, now starting the real build.
Checking build tools versions...
************************************************************
You are attempting to build with the incorrect version
of java.

Your version is: java version "1.6.0_20".
The correct version is: 1.5.

Please follow the machine setup instructions at
    http://source.android.com/download
************************************************************
build/core/main.mk:111: *** stop.  中止.

あちゃー openjdk-6-jdk じゃだめだったかsun-java6-jdkやってみる。
レポジトリ追加してインストールできるようにする

$ sudo add-apt-repository "deb http://archive.canonical.com/ maverick partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
ライセンスに同意する。

java環境を切り替える
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                      優        Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      auto mode
  1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-6-sun/jre/bin/java       63        manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-6-sun/jre/bin/java to provide /usr/bin/java (java) in manual mode.

うええ。やはりsun-java-5-jdkじゃないとダメ?
→ sun-java-5-jdk見つからない。

結局元に戻す。
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b eclair
$ repo sync

http://blog.sola-dolphin-1.net/archives/3013670.html 経由で 32bit でもbuildする方法を適用
http://groups.google.com/group/android-platform/browse_thread/thread/b0bb991131589363?hl=en
$ cp -a build/core/main.mk{,.o}
$ vi build/core/main.mk
$ cp -a external/clearsilver/cgi/Android.mk{,.o}
$ vi external/clearsilver/cgi/Android.mk
$ cp -a external/clearsilver/java-jni/Android.mk{,.o}
$ vi external/clearsilver/java-jni/Android.mk
$ cp -a external/clearsilver/util/Android.mk{,.o}
$ vi external/clearsilver/util/Android.mk
$ cp -a external/clearsilver/cs/Android.mk{,.o}
$ vi external/clearsilver/cs/Android.mk

$ make -j2
Install: out/target/product/generic/system/bin/system_server
Install: out/target/product/generic/system/lib/libandroid_servers.so
target Prelink: libwebcore (out/target/product/generic/symbols/system/lib/libwebcore.so)
target Strip: libwebcore (out/target/product/generic/obj/lib/libwebcore.so)
Install: out/target/product/generic/system/lib/libwebcore.so
target Executable: webcore_test (out/target/product/generic/obj/EXECUTABLES/webcore_test_intermediates/LINKED/webcore_test)
Finding NOTICE files: out/target/product/generic/obj/NOTICE_FILES/hash-timestamp
target Non-prelinked: webcore_test (out/target/product/generic/symbols/system/bin/webcore_test)
target Strip: webcore_test (out/target/product/generic/obj/EXECUTABLES/webcore_test_intermediates/webcore_test)
Combining NOTICE files: out/target/product/generic/obj/NOTICE.html
Target system fs image: out/target/product/generic/obj/PACKAGING/systemimage_unopt_intermediates/system.img
Install system fs image: out/target/product/generic/system.img
Installed file list: out/target/product/generic/installed-files.txt

エミュレータを使えるようにする
$ cd out/host/linux-x86/bin/
$ mkdir -p lib/images
$ cd lib/images
$ ln -s ../../../../../../out/target/product/generic/ramdisk.img .
$ ln -s ../../../../../../out/target/product/generic/system.img .
$ ln -s ../../../../../../out/target/product/generic/userdata.img .
$ ln -s ../../../../../../development/e
$ cd ../../
$ ./emulator -wipe-dataemulator: ERROR: You did not provide the name of an Android Virtual Device
with the '-avd <name>' option. Read -help-avd for more information.

If you *really* want to *NOT* run an AVD, consider using '-data <file>'
to specify a data partition image file (I hope you know what you're doing).

Android仮想デバイス(AVD)というものが必要らしい。

$ ./android
SWT folder '/home/hato/public/android/out/host/linux-x86/framework/x86' does not exist.
Please export ANDROID_SWT to point to the folder containing swt.jar for your platform.
$ cp -a ./prebuilt/linux-x86/swt/swt.jar ./out/host/linux-x86/framework/x86/

$ mkdir /home/hato/public/android/out/host/linux-x86/framework/x86
$ cp -a ../framework/swt.jar /home/hato/public/android/out/host/linux-x86/framework/x86

$ ./android list targets
Error: Error parsing the sdk.
Error: /home/hato/public/android/out/host/linux-x86/platforms is missing.
Error: Unable to parse SDK content.

$ mkdir /home/hato/public/android/out/host/linux-x86/platforms/
$ cp -a /home/hato/public/android/ndk/build/platforms/*
 /home/hato/public/android/out/host/linux-x86/platforms/

$ out/host/linux-x86/bin/android list targets
Error: Error parsing the sdk.
Error: /home/hato/public/android/out/host/linux-x86/add-ons is missing.
Error: Unable to parse SDK content.
$ mkdir /home/hato/public/android/out/host/linux-x86/add-ons

$ out/host/linux-x86/bin/android list targets
Available Android targets:

からっぽ? やり方がそもそも違うらしい
これらしい http://android.akjava.com/cms/develop/sdk/install.html

$ cd out/host/linux-x86/
$ wget http://dl.google.com/android/android-sdk_r07-linux_x86.tgz
$ tar xzvf 

・・なんか起動したけど・・・?

上記エミュレータを起動して仮想デバイスを作成。
作った仮想デバイスは ~/.android/に保存されるのでこれにビルドしたものを差し替えたりすればいいのかしらん。
$ find $ find .
.
./default.keyset
./repositories.cfg
./androidtool.cfg
./avd
./avd/test.ini
./avd/test.avd
./avd/test.avd/userdata.img
./avd/test.avd/emulator-user.ini
./avd/test.avd/cache.img
./avd/test.avd/sdcard.img
./avd/test.avd/config.ini
./avd/test.avd/userdata-qemu.img