Search code examples
androidadbndk-buildadbd

How to build Android's adb from source code?


I'm trying to build Android's adb from source code, which I downloaded from here.

I tried to use NDK21 and its ndk-build, but got this error

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.

I have found this question on stackoverflow with the similar problem, and tried to apply the answer from there. Downloaded the patched version of NDK7 from here and tried to build adb with it, but still got a similar error

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.

All other solutions for Trying to define local module ... this module was already defined problem advise to change Android.mk file, but I have it from original source code, so I suppose it must be correct in the first place.

What else can I try to build adb?

Thank you in advance.


Solution

  • The mentioned project is part of AOSP and should be built within AOSP build but it seems that it is already outdated because AOSP master is now using this one: https://android.googlesource.com/platform/packages/modules/adb/+/refs/heads/master