build android adb on debian sid amd64

16 March 2010 - 3:18pm — abate

I've installed android on my freerunner. I've to say that it works ! very nice and functional interface, finger friendly, voice, sms, wifi work out of the box. I'm very impressed.

Following the lead from http://lackingrhoticity.blogspot.com/2010/02/how-to-build-adb-android-debugger.html I've decided to build adb to connect to my phone without downloading the precompiled sdk and without checking-out the entire android git repository. It's actually very easy, and I'm sure with a minimal effort, it should be possible to create a debian package. The android instructions give some hints regarding the cross-compilation of android on a x64 machine.

Cutting and pasting from Lacking Rhoticity blog you need to :

$ sudo apt-get install build-essential libncurses5-dev
$ git clone git://android.git.kernel.org/platform/system/core.git system/core
$ git clone git://android.git.kernel.org/platform/build.git build
$ git clone git://android.git.kernel.org/platform/external/zlib.git external/zlib
$ git clone git://android.git.kernel.org/platform/bionic.git bionic
$ echo "include build/core/main.mk" >Makefile

Now edit build/core/main.mk and comment out the parts labelled

# Check for the correct version of java

and

# Check for the correct version of javac

Since adb doesn't need Java, these checks are unnecessary.

Also edit build/target/product/sdk.mk and comment out the "include" lines after

# include available languages for TTS in the system image


Now, since we are one a x64 machine we need to install the rest of the libraries to cross compile abd. I think this is the minimum you need to successfully build adb

sudo apt-get install libc6-dev-i386 lib32ncurses5-dev ia32-libs g++-multilib

The result should be something like this :

$make out/host/linux-x86/bin/adb
============================================
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
============================================
find: `frameworks/base/api': No such file or directory
[ ... ]
host Executable: adb (out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb)
true
host C: acp <= build/tools/acp/acp.c
host C++: libhost <= build/libs/host/pseudolocalize.cpp
host C: libhost <= build/libs/host/CopyFile.c
host StaticLib: libhost (out/host/linux-x86/obj/STATIC_LIBRARIES/libhost_intermediates/libhost.a)
ar crs  out/host/linux-x86/obj/STATIC_LIBRARIES/libhost_intermediates/libhost.a out/host/linux-x86/obj/STATIC_LIBRARIES/libhost_intermediates/pseudolocalize.o out/host/linux-x86/obj/STATIC_LIBRARIES/libhost_intermediates/CopyFile.o
host Executable: acp (out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp)
true
Install: out/host/linux-x86/bin/acp
Notice file: system/core/adb/NOTICE -- out/host/linux-x86/obj/NOTICE_FILES/src//bin/adb.txt
Notice file: system/core/libzipfile/NOTICE -- out/host/linux-x86/obj/NOTICE_FILES/src//lib/libzipfile.a.txt
Notice file: external/zlib/NOTICE -- out/host/linux-x86/obj/NOTICE_FILES/src//lib/libunz.a.txt
Notice file: system/core/liblog/NOTICE -- out/host/linux-x86/obj/NOTICE_FILES/src//lib/liblog.a.txt
Notice file: system/core/libcutils/NOTICE -- out/host/linux-x86/obj/NOTICE_FILES/src//lib/libcutils.a.txt
Install: out/host/linux-x86/bin/adb

Running abd :

$ADBHOST=192.168.0.202 ./out/host/linux-x86/bin/adb devices
* daemon not running. starting it now *
* daemon started successfully *
List of devices attached
emulator-5554    device

###################################################

$ sudo apt-get install build-essential libncurses5-dev
$ git clone https://android.googlesource.com/system/core.git system/core
$ git clone https://android.googlesource.com/platform/build.git build
$ git clone https://android.googlesource.com/platform/external/zlib external/zlib
$ git clone https://android.googlesource.com/platform/bionic.git bionic
$ echo "include build/core/main.mk" >Makefile