如何从源代码构建 Android 的 adb?

How to build Android's adb from source code?

我正在尝试从源代码构建 Android 的 adb,源代码是我从 here 下载的。

我尝试使用 NDK21 及其 ndk-build,但出现此错误

Android NDK: APP_PLATFORM not set. Defaulting to minimum supported version android-16.
Android NDK: Trying to define local module 'adbd' in C:\Users\...\adb/jni/Android.mk.
Android NDK: But this module was already defined by C:\Users\...\adb/jni/Android.mk.
C:/Users/.../android-ndk-r21d-windows-x86_64/android-ndk-r21d/build//../build/core/build-module.mk:34: *** Android NDK: Aborting.    .  Stop.

我找到了 this question on Whosebug with the similar problem, and tried to apply the answer from there. Downloaded the patched version of NDK7 from here 并尝试用它构建 adb,但仍然出现类似的错误

C:\Users\...\adb/jni/Android.mk:8: C:\Users\...\adb/jni/../platform_tools_tool_version.mk: No such file or directory
Android NDK: Trying to define local module 'adb' in C:\Users\...\adb/jni/Android.mk.
Android NDK: But this module was already defined by C:\Users\...\adb/jni/Android.mk.
C:/Users/.../android-ndk-r7b-master/android-ndk-r7b-master/build/core/build-module.mk:34: *** Android NDK: Aborting.    .  Stop.

Trying to define local module ... this module was already defined 问题的所有其他解决方案建议更改 Android.mk 文件,但我从原始源代码中获得了它,所以我想它首先必须是正确的。

我还能尝试构建 adb 什么?

提前致谢。

提到的项目是 AOSP 的一部分,应该在 AOSP build 中构建,但它似乎已经过时了,因为 AOSP master 现在正在使用这个:https://android.googlesource.com/platform/packages/modules/adb/+/refs/heads/master