Search code examples
androidandroid-source

building android sdk tools (aapt, adb, etc.) for arm/arm64


I am currently interested in building the Android SDK tools (aapt, adb, etc.) for the ARM-v7a and ARM64-v8a architectures so that it can be run directly on an Android device. Is this possible?

I was able to build the Android SDK tools for x86/x86_64 pretty easily following the documentation.

https://source.android.com/setup

To do this, I performed the following steps.

  mkdir ~/WORKING_DIRECTORY
  cd ~/WORKING_DIRECTORY

  repo init -u https://android.googlesource.com/platform/manifest -b master -g all,-notdefault,tools
  repo sync

  . build/envsetup.sh
  lunch sdk-eng
  make sdk

As mentioned above, this will build the android SDK tools for x86/x86_64. I am just not sure how I can build the tools for other architectures.

I am aware that you can specify the desired architecture to the make targets. For example, "make aosp_arm-eng" which will build the image for the arm environment. However, when I tried "make sdk_arm-eng", it told me that the target did not exist.

Any help would be greatly appreciated.

EDIT:

It looks like Debian has arm/arm64 packages for aapt and other android tools here.

https://packages.debian.org/buster/aapt

However, these will be unable to run on the actual android device it seems because of dependencies.

/android-sdk/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-readelf -a aapt | grep Shared

  Type:                              DYN (Shared object file)
 0x0000000000000001 (NEEDED)             Shared library: [libaapt.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libutils.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [ld-linux-aarch64.so.1]

As we can see below, it requires libgcc libstc++ which isn't packaged with android.


Solution

  • I ended up just building aapt myself from the AOSP source code. This was much easier than I initially thought. To do this, I modified the build script to build the binaries for the "target" architecture instead of the "host" architecture.

    https://android.googlesource.com/platform/frameworks/base/+/master-soong/tools/aapt/Android.bp

    The built binaries are here in case anyone else needs them.

    https://github.com/thejunkjon/android-tools