|
How to build adb, the Android debugger adb is the Android debugger (officially the “Android debug bridge” I think). It is a tool for getting shell access to an Android phone across a USB connection. It can also be used to copy files to and from the Android device and do port-forwarding. In short, it is similar to ssh, but is not ssh. (Why couldn’t they have just used ssh?) I have not been able to find any Debian/Ubuntu packages for adb. The reason why it has not been packaged becomes apparent if you try to build the thing. Android has a monolithic build system which wants to download a long list of Git repositories and build everything. If you follow the instructions, it will download 1.1Gb from Git and leave you with a source+build directory of 6Gb. It isn’t really designed for building subsets of components, unlike, say, JHBuild. It’s basically a huge makefile. It doesn’t know about dependencies between components. However, it does have some idea about dependencies between output files. Based on a build-of-all-Android, I figured out how to build a much smaller subset containing adb. This downloads a more manageable 11Mb and finishes with a source+build directory containing 40Mb. This is also preferable to downloading the pre-built Android SDK, which has a non-free licence. Instructions: $ sudo apt-get install build-essential libncurses5-dev 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 I don’t know exactly what this is about but it avoids having to download language files that aren’t needed for adb. Then building the adb target should work: make out/host/linux-x86/bin/adb If you try running “adb shell” you might get this: ubuntu$ ./out/host/linux-x86/bin/adb shell So you probably need to do “adb start-server” as root first: ubuntu$ sudo ./out/host/linux-x86/bin/adb kill-server For the record, here are the errors I got that motivated each step:
The instructions above will probably stop working as new versions are pushed to the public Git branches. (However, this happens infrequently because Android development is not done in the open.) For reproducibility, here are the Git commit IDs: $ find -name "*.git" -exec sh -c 'echo "`git --git-dir={} rev-parse HEAD` {}"' ';' It looks like the current version is Android 1.6 (Donut): $ find -name "*.git" -exec sh -c 'echo "`git --git-dir={} describe` {}"' ';' 源文档 <http://androidboss.com/how-to-build-adb-the-android-debugger/> (androidboss) |
