Giter VIP home page Giter VIP logo

android-tools's Introduction

android-tools

Git repository to make it easier to package certain command line utilities provided by android-tools.

Motivation

Many Linux distributions have a package called android-tools which ships essential android command line tools like adb or fastboot. Sadly the upstream build system for those tools is rather complex and doesn't allow building the command line tools only.

Linux Distribution therefore mostly ship their own build systems for building the command line utilities. This repository aims to make packaging of android command utilities easier by providing a simple CMake based build system and a ready-to-use tarball which doesn't require cloning all of the required git repositories manually. Besides this makes it easy to collect all patches required to build standalone android command line utilities in a central place.

Status

Currently the following tools are supported:

  • adb
  • fastboot
  • mke2fs.android (required by fastboot)
  • simg2img, img2simg, append2simg
  • lpdump, lpmake, lpadd, lpflash, lpunpack
  • mkbootimg, unpack_bootimg, repack_bootimg, avbtool
  • mkdtboimg

The build system itself works quite well and is already being used for the Alpine Linux android-tools package which I maintain.

I personally don't use any android-tools except adb and fastboot. Thus my motivation to add support for additional tools is rather low at the moment. However, patches adding support for new tools in a clean way are welcome. Additionally, patches needed to make the software compile on other Linux distributions are welcome as well. Please create new patches using git format-patch --no-numbered --no-signature ….

Dependencies

The following libraries are required by android-tools:

  1. libusb
  2. PCRE
  3. Google Test
  4. protobuf
  5. brotli
  6. zstd
  7. lz4

Python 3 is optionally needed as a run-time dependency in order to use the mkbootimg, unpack_bootimg, and repack_bootimg scripts which are all written in Python.

Additionally the following software is required at compile-time:

  1. A C and C++ compiler (either GCC >= 10.X or clang)
  2. The Go compiler
  3. CMake
  4. Perl

Currently the build system doesn't check whether all of these are installed.

Installation

Source tarballs containing an already patched version of all vendored dependencies are available on the GitHub Release Page.

These tarballs should be used for packaging and general installation. After the tarball was downloaded and extracted android-tools can be build and installed as follows:

$ mkdir build && cd build
$ cmake ..
$ make
$ make install

Generating tarballs

New source tarballs can be created from the Git repository using:

$ mkdir build && cd build
$ cmake ..
$ make package_source

Before a new release is uploaded a new git-tag(1) should be created for the release. Afterwards the tarball can be uploaded to the GitHub Release Page.

See also

The build script for android platform tools by Anatol Pomozov which inspired this project. Most definitions in the CMakeLists.txt have been copied from Anatol's ruby script.

android-tools's People

Contributors

anatol avatar biswa96 avatar csfore avatar decatf avatar jamikettunen avatar jamim avatar jershell avatar johnnynator avatar lweiss-fairphone avatar moetayuko avatar munix9 avatar nmeum avatar noraj avatar sgn avatar spriteovo avatar stephan-gh avatar vanaf avatar xeonacid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-tools's Issues

adb connect not working

The issue is an over-patching in core/0026-adb-disable-mDNS.patch/adb/socket_spec.cpp preventing any outer tcp-connection.

Even if we remove mDNS, the patched place in socket_spec.cpp MUST contain the code

 if (tcp_host_is_local(hostname)) {
            fd->reset(network_loopback_client(port_value, SOCK_STREAM, error));
        } else {
            fd->reset(network_connect(hostname, port_value, SOCK_STREAM, 0, error));
        }

The current release has no the "else" part

does not compile with fmt >= 8

[  345s] In file included from /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.h:23,
[  345s]                  from /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:17:
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::DataUpdater::Seek(uint32_t)::<lambda()>::FMT_COMPILE_STRING; Args = {unsigned int, long unsigned int}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:81:37:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:197:57: error: 'fmt' is not a constant expression
[  345s]   197 |   return Error(false, ErrorCode(0, args...), fmt::format(fmt, args...));
[  345s]       |                                              ~~~~~~~~~~~^~~~~~~~~~~~~~
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::DataUpdater::CheckOffset(uint32_t, uint32_t)::<lambda()>::FMT_COMPILE_STRING; Args = {unsigned int, long int}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:94:20:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:197:57: error: 'fmt' is not a constant expression
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::DataUpdater::CheckOffset(uint32_t, uint32_t)::<lambda()>::FMT_COMPILE_STRING; Args = {unsigned int, long int}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:97:20:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:197:57: error: 'fmt' is not a constant expression
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::DataUpdater::CheckAdvance(const char*, const char*, uint32_t, const char*)::<lambda()>::FMT_COMPILE_STRING; Args = {const char*, const void*, unsigned int, const void*}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:116:20:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:197:57: error: 'fmt' is not a constant expression
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::DataUpdater::CheckAdvance(const char*, const char*, uint32_t, const char*)::<lambda()>::FMT_COMPILE_STRING; Args = {const char*, const void*, unsigned int, const void*}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:119:20:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:197:57: error: 'fmt' is not a constant expression
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::get_vendor_boot_header_size(const vendor_boot_img_hdr_v3*)::<lambda()>::FMT_COMPILE_STRING; Args = {unsigned int}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:133:12:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:197:57: error: 'fmt' is not a constant expression
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::check_vendor_boot_hdr(const string&, uint32_t)::<lambda()>::FMT_COMPILE_STRING; Args = {long unsigned int, long unsigned int}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:141:16:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:197:57: error: 'fmt' is not a constant expression
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::check_vendor_boot_hdr(const string&, uint32_t)::<lambda()>::FMT_COMPILE_STRING; Args = {long unsigned int, unsigned int, unsigned int}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:149:16:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:197:57: error: 'fmt' is not a constant expression
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::check_vendor_boot_hdr(const string&, uint32_t)::<lambda()>::FMT_COMPILE_STRING; Args = {}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:153:16:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:197:57: error: 'fmt' is not a constant expression
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::check_vendor_boot_hdr(const string&, uint32_t)::<lambda()>::FMT_COMPILE_STRING; Args = {unsigned int, unsigned int}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:156:16:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:197:57: error: 'fmt' is not a constant expression
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrnoErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::load_file(android::base::borrowed_fd, uint64_t, const char*)::<lambda()>::FMT_COMPILE_STRING; Args = {const char*}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:165:16:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:202:40: error: 'fmt' is not a constant expression
[  345s]   202 |   return Error(true, errno, fmt::format(fmt, args...));
[  345s]       |                             ~~~~~~~~~~~^~~~~~~~~~~~~~
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrnoErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::load_file(android::base::borrowed_fd, uint64_t, const char*)::<lambda()>::FMT_COMPILE_STRING; Args = {const char*}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:169:16:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:202:40: error: 'fmt' is not a constant expression
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::load_file(android::base::borrowed_fd, uint64_t, const char*)::<lambda()>::FMT_COMPILE_STRING; Args = {const char*, long unsigned int, long unsigned int}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:172:16:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:197:57: error: 'fmt' is not a constant expression
[  345s]   197 |   return Error(false, ErrorCode(0, args...), fmt::format(fmt, args...));
[  345s]       |                                              ~~~~~~~~~~~^~~~~~~~~~~~~~
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrnoErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::store_file(android::base::borrowed_fd, const string&, const char*)::<lambda()>::FMT_COMPILE_STRING; Args = {const char*}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:182:16:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:202:40: error: 'fmt' is not a constant expression
[  345s]   202 |   return Error(true, errno, fmt::format(fmt, args...));
[  345s]       |                             ~~~~~~~~~~~^~~~~~~~~~~~~~
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrnoErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::store_file(android::base::borrowed_fd, const string&, const char*)::<lambda()>::FMT_COMPILE_STRING; Args = {const char*}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:185:16:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:202:40: error: 'fmt' is not a constant expression
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrnoErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::store_file(android::base::borrowed_fd, const string&, const char*)::<lambda()>::FMT_COMPILE_STRING; Args = {long unsigned int}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:188:16:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:202:40: error: 'fmt' is not a constant expression
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::find_unique_ramdisk(const string&, const vendor_ramdisk_table_entry_v4*, uint32_t)::<lambda()>::FMT_COMPILE_STRING; Args = {const char*}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:286:24:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:197:57: error: 'fmt' is not a constant expression
[  345s]   197 |   return Error(false, ErrorCode(0, args...), fmt::format(fmt, args...));
[  345s]       |                                              ~~~~~~~~~~~^~~~~~~~~~~~~~
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::find_unique_ramdisk(const string&, const vendor_ramdisk_table_entry_v4*, uint32_t)::<lambda()>::FMT_COMPILE_STRING; Args = {const char*}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:293:16:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:197:57: error: 'fmt' is not a constant expression
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrorfImpl(const T&&, const Args& ...) [with T = {anonymous}::replace_vendor_ramdisk_fragment(const string&, const string&, const string&)::<lambda()>::FMT_COMPILE_STRING; Args = {}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:315:16:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:197:57: error: 'fmt' is not a constant expression
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h: In instantiation of 'android::base::Error android::base::ErrorfImpl(const T&&, const Args& ...) [with T = replace_vendor_ramdisk(android::base::borrowed_fd, uint64_t, const string&, android::base::borrowed_fd, uint64_t)::<lambda()>::FMT_COMPILE_STRING; Args = {}]':
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/core/fastboot/vendor_boot_img_utils.cpp:403:16:   required from here
[  345s] /home/abuild/rpmbuild/BUILD/android-tools-31.0.2/vendor/libbase/include/android-base/result.h:197:57: error: 'fmt' is not a constant expression
[  345s] make[2]: *** [vendor/CMakeFiles/fastboot.dir/build.make:205: vendor/CMakeFiles/fastboot.dir/core/fastboot/vendor_boot_img_utils.cpp.o] Error 1
[  345s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/android-tools-31.0.2/build'
[  345s] make[1]: *** [CMakeFiles/Makefile2:1012: vendor/CMakeFiles/fastboot.dir/all] Error 2
[  345s] make[1]: *** Waiting for unfinished jobs....

openSUSE Tumbleweed
gcc 11.1.1
fmt 8.0.1

Use Github Actions for (test) builds

Maybe it would be useful to use Github Actions for (test) builds.
I have already tested this for openSUSE Tumbleweed:
https://github.com/munix9/android-tools/tree/master-actions/.github/workflows
https://github.com/munix9/android-tools/tree/platform-tools-31_0_2-actions/.github/workflows

This is certainly expandable, also for other distris. It could also be used to build a new release and the corresponding package.

The handling of Github Actions with different branches is currently a bit tedious (default-branch must be changed accordingly).

Build failure with gcc 11

With the (yet to be released) GCC 11 compilation of boringssl fails (for instance on Fedora 34) with the following error message:

In file included from /home/nmeum/android-tools/vendor/boringssl/crypto/fipsmodule/bcm.c:38:
/home/nmeum/android-tools/vendor/boringssl/crypto/fipsmodule/bn/asm/x86_64-gcc.c:427:51: error: argument 2 of type ‘const uint64_t[8]’ {aka ‘const long unsigned int[8]’} with mismatched bound [-Werror=array-parameter=]
  427 | void bn_sqr_comba8(BN_ULONG r[16], const BN_ULONG a[8]) {
      |                                    ~~~~~~~~~~~~~~~^~~~
In file included from /home/nmeum/android-tools/vendor/boringssl/crypto/fipsmodule/bn/add.c:64,
                 from /home/nmeum/android-tools/vendor/boringssl/crypto/fipsmodule/bcm.c:37:
/home/nmeum/android-tools/vendor/boringssl/crypto/fipsmodule/bn/internal.h:292:51: note: previously declared as ‘const uint64_t[4]’ {aka ‘const long unsigned int[4]’}
  292 | void bn_sqr_comba8(BN_ULONG r[16], const BN_ULONG a[4]);
      |                                    ~~~~~~~~~~~~~~~^~~~
In file included from /home/nmeum/android-tools/vendor/boringssl/crypto/fipsmodule/bcm.c:100:
/home/nmeum/android-tools/vendor/boringssl/crypto/fipsmodule/sha/sha256.c: In function ‘SHA224_Final’:
/home/nmeum/android-tools/vendor/boringssl/crypto/fipsmodule/sha/sha256.c:122:10: error: ‘SHA256_Final’ accessing 32 bytes in a region of size 28 [-Werror=stringop-overflow=]
  122 |   return SHA256_Final(out, ctx);
      |          ^~~~~~~~~~~~~~~~~~~~~~
/home/nmeum/android-tools/vendor/boringssl/crypto/fipsmodule/sha/sha256.c:122:10: note: referencing argument 1 of type ‘uint8_t *’ {aka ‘unsigned char *’}
/home/nmeum/android-tools/vendor/boringssl/crypto/fipsmodule/sha/sha256.c:172:20: note: in a call to function ‘SHA256_Final’
  172 | #define HASH_FINAL SHA256_Final
      |                    ^~~~~~~~~~~~
/home/nmeum/android-tools/vendor/boringssl/crypto/fipsmodule/sha/../digest/md32_common.h:231:5: note: in expansion of macro ‘HASH_FINAL’
  231 | int HASH_FINAL(uint8_t out[HASH_DIGEST_LENGTH], HASH_CTX *c) {
      |     ^~~~~~~~~~
In file included from /home/nmeum/android-tools/vendor/boringssl/crypto/fipsmodule/bcm.c:101:
/home/nmeum/android-tools/vendor/boringssl/crypto/fipsmodule/sha/sha512.c: In function ‘SHA384_Final’:
/home/nmeum/android-tools/vendor/boringssl/crypto/fipsmodule/sha/sha512.c:137:10: error: ‘SHA512_Final’ accessing 64 bytes in a region of size 48 [-Werror=stringop-overflow=]
  137 |   return SHA512_Final(out, sha);
      |          ^~~~~~~~~~~~~~~~~~~~~~
/home/nmeum/android-tools/vendor/boringssl/crypto/fipsmodule/sha/sha512.c:137:10: note: referencing argument 1 of type ‘uint8_t *’ {aka ‘unsigned char *’}
/home/nmeum/android-tools/vendor/boringssl/crypto/fipsmodule/sha/sha512.c:196:5: note: in a call to function ‘SHA512_Final’
  196 | int SHA512_Final(uint8_t out[SHA512_DIGEST_LENGTH], SHA512_CTX *sha) {
      |     ^~~~~~~~~~~~
cc1: all warnings being treated as errors

This does not seem to be specific to this repository though as the same build failure occurs with boringssl git HEAD (6b48efac7b3b229c17cff55e5cfd9f9a0aea9b70). Regarding the specific warnings: The first seems to be mismatch between function prototype and function implementation. The second seems to be an array size mismatch which doesn't seem to be a real issue though as the passed HASH_CTX contains the amount of bytes which should actually be accessed. I think it would be best to report this to boringssl upstream. Unfortunately, their issue tracker requires a google account and I don't have one and don't plan on creating one.

Get other distros on board

Hey @nmeum, thanks for creating this repository. I've found it from the Alpine aport in testing, and I think it makes a lot of sense to provide a sane build system for android-tools.

How about asking the maintainers of the packages in the other distributions you mentioned in the README.md, if they would like to use this source repository as well (so we have more eyeballs on it, and possibly more people maintaining it)?

PS: The link to the Void Linux package is outdated.

How to compile with Cygwin64

Hi,

I want to compile this project using Cygwin64. The reason is to obtain binaries based on Linux sources in Windows. I know that the Windows versions are included in the package. But the code is different, so I really need to have a Windows binary linked to cygwin1.dll

So, I've found some troubles, compiling it and I request your help:

  1. The missing go compiler in the Cygwin environment. Because this compiler is missing in the packages, I've installed the Windows version. It's accessible to the Cygwin shell and also to WSL (I want to check first compiling in WSL with the Go windows version). Here the command to configure the CMake with Go for windows:
    • WSL: cmake -DGO_EXECUTABLE=/mnt/e/Go/bin/go.exe ..
    • Cygwin64: cmake -DGO_EXECUTABLE=/cygdrive/E/Go/bin/go.exe ..
  2. This pass all the configuration phase when the needed libraries and tools are installed. However, when compiling in WSL I see this error: go: RLock \\wsl$\Ubuntu\home\dani\dev\android-tools\android-tools-33.0.3p1\vendor\boringssl\go.mod: Incorrect function.
    So I suspect that when the compiling will arrive to this point in the Cygwin64 environment the same error will appears. Any idea to fix this problem? Or almost how to compile with an external go compiler (missing in Cygwin64). Or how to overcome the compilation of the boringssl that is the only part that requires the Go compiler?
  3. Another problem is the compilation of some code with the Cygwin64 toolchain. For example, I obtain this:
[  1%] Building CXX object vendor/CMakeFiles/liblog.dir/logging/liblog/logprint.cpp.o
/home/user/adb/android-tools-33.0.3p1/vendor/logging/liblog/logprint.cpp: In the function ‘int android_log_addFilterString(AndroidLogFormat*, const char*)’:
/home/user/adb/android-tools-33.0.3p1/vendor/logging/liblog/logprint.cpp:465:27: error: ‘strsep’ was not declared in this scope; did you mean ‘strstr’?
  465 |   while (NULL != (p_ret = strsep(&p_cur, " \t,"))) {
      |                           ^~~~~~
      |                           strstr
make[2]: *** [vendor/CMakeFiles/liblog.dir/build.make:160: vendor/CMakeFiles/liblog.dir/logging/liblog/logprint.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:539: vendor/CMakeFiles/liblog.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

Any idea to fix this?

I hope you want to help me to compile this package with Cygwin.
Thank you.

Build error after latest tarball : /usr/bin/ld: cannot open output file adb: Is a directory

After latest tarballs release now i get this build error :

[ 64%] Linking CXX executable adb
/usr/bin/ld: cannot open output file adb: Is a directory
collect2: error: ld returned 1 exit status
make[2]: *** [vendor/CMakeFiles/adb.dir/build.make:376: vendor/adb] Error 1
make[1]: *** [CMakeFiles/Makefile2:680: vendor/CMakeFiles/adb.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

Build failure with Kernel >= 6.0: error: flexible array member ‘usbdevfs_urb::iso_frame_desc’ not at end of ‘struct usb_handle’

On Kernel 6.0-rc6 with gcc 12.1, building android-tools 33.0.3 fails with the following error:

/usr/lib/ccache/bin/g++ -DADB_HOST=1 -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -I/home/mae/.cache/kiss/proc/121205/build/android-tools/build/vendor -I/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/base/libs/androidfw/include -I/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/boringssl/include -I/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb -I/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/crypto/include -I/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/pairing_auth/include -I/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/pairing_connection/include -I/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/tls/include -I/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/core/include -I/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/core/libcrypto_utils/include -I/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/core/libcutils/include -I/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/libbase/include -I/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/libziparchive/include -I/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/native/include -march=x86-64-v3 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Wno-error=format-security -fstack-clash-protection -fcf-protection -Wp,-D_GLIBCXX_ASSERTIONS -O3 -DNDEBUG -Wno-attributes -std=gnu++20 -MD -MT vendor/CMakeFiles/libadb.dir/adb/client/usb_linux.cpp.o -MF vendor/CMakeFiles/libadb.dir/adb/client/usb_linux.cpp.o.d -o vendor/CMakeFiles/libadb.dir/adb/client/usb_linux.cpp.o -c /home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp
In file included from /home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:28:
/usr/include/linux/usbdevice_fs.h:134:41: error: flexible array member ‘usbdevfs_urb::iso_frame_desc’ not at end of ‘struct usb_handle’
  134 |         struct usbdevfs_iso_packet_desc iso_frame_desc[];
      |                                         ^~~~~~~~~~~~~~
/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:76:18: note: next member ‘usbdevfs_urb usb_handle::urb_out’ declared here
   76 |     usbdevfs_urb urb_out;
      |                  ^~~~~~~
/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:61:8: note: in the definition of ‘struct usb_handle’
   61 | struct usb_handle {
      |        ^~~~~~~~~~

Build script:

cmake -B build -G Ninja \
    -D CMAKE_INSTALL_PREFIX=/usr \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_C_FLAGS="${CFLAGS}" \
    -D CMAKE_CXX_FLAGS="${CXXFLAGS}"

sed -i "s|-Werror|-Wno-error|g" build/build.ninja

ninja -C build
ninja -C build install

Flags:

export CFLAGS='-march=x86-64-v3 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection'
export CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
export LDFLAGS='-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

fastboot format cannot generate f2fs image

It tries to call make_f2fs which doesn't exist. Perhaps just instead calling mkfs.f2fs would be enough?

$ fastboot --version
fastboot version 34.0.0-android-tools
Installed as /usr/bin/fastboot
$ fastboot format:f2fs userdata
/usr/bin/make_f2fs failed with status 1
fastboot: error: Cannot generate image for userdata

re-enable avbtool

as far as I can see it is ported to python3.

It would be really nice to have for signing your own partitions

Acceleration cloning and reduce the size of submodules

Hello, nmeum. I don't have an error message, just a suggestion, if you'll let me. I recently work with GitHub and decided to experiment with my fork of your repository. In my fork, I added shallow = true to the file .gitmodules in the settings of each submodule. Here are my results for comparison:

My connection speed: 25 Mbit/Sec

Cloning android-tools from my fork with submodules:
Beginning: 09:43
Ending: 10:05
Total time: 22 minutes
Size ./android-tools/vendor/base - 2GB
Size ./android-tools/vendor/extras - 887MB
Overall size ./android-tools: ~5,2GB

Cloning android-tools from the nmeum repository with submodules:
Beginning: 10:08
Ending: 10:48
Total time: 40 minutes
Size ./android-tools/vendor/base - 3GB
Size ./android-tools/vendor/extras - 1,2GB
Overall size ./android-tools: ~7GB

Result:
The total size after cloning is less by ~2GB, the time spent on cloning is less by ~20 minutes. And all this without prejudice to further manipulations with the source code, since the build also passes without errors.

The sad thing is that, for example, from the same directory ./vendor/base, which weighs 2-3GB, only the 6MB libs folder is required. However, as far as I understood after reading several articles, it is impossible to clone only selected folders on GitHub. However, the shallow = true option turned out to be useful. Maybe you would consider including it in your file .gitmodules, if it doesn't hurt anything in the future? :)

my fork: https://github.com/AKotov-dev/android-tools/tree/platform-tools-31.0.2

There is also a script cleanup-for-tar.xz.sh to clean up before preparing to compress into the final archive with the *.tar.xz fixes (since I do not know how exactly you exclude everything unnecessary from such a large abundance of source code).

Sincerely,
Alex :)

android-tools doesn't build for non-x86* arches

(I did not look into this much yet, this is more of an FYI that a downstream bugreport exists.)

The bundled boringssl fails to compile on Alpine for non-x86* arches. Maybe we can make it use the system's openssl instead?

Last build from Alpine:
http://build.alpinelinux.org/buildlogs/build-edge-armhf/testing/android-tools/android-tools-9.0.0_p3-r1.log

Downstream bugreport (user missing it for aarch64):
https://gitlab.com/postmarketOS/pmbootstrap/issues/1682

Adding a license

I would like to add a license to this repository. I believe this to be useful for downstream Linux distributions, with some even requiring OSI/FSF approved licenses. I would suggest simply using Apache-2.0 since that's what Android itself uses. The problem is: I am not the only one how contributed code to this repository so my naive legal understanding is that I cannot just go ahead and commit a license file. The following people have committed code to this repository:

Would you mind licensing this repository under Apache-2.0? Any suggestions on how to best record this consent as part of the commit history?

vendor/core/NOTICE is gone in 31.0.2

vendor/core/NOTICE is gone in 31.0.2 so this leads to an error in make install

See upstream
https://android.googlesource.com/platform/system/core.git/+log/refs/tags/platform-tools-31.0.2/NOTICE
https://android.googlesource.com/platform/system/core.git/+/2f51435809f29d2fa3e3dab82617813c121e9721

See github actions build
https://github.com/munix9/android-tools/runs/2703531103?check_suite_focus=true#step:7:2184

Install the project...
/usr/bin/cmake -P cmake_install.cmake
-- Install configuration: "Release"
-- Installing: /usr/local/share/bash-completion/completions/adb
-- Installing: /usr/local/share/bash-completion/completions/fastboot
-- Installing: /usr/local/share/zsh/site-functions/_adb
-- Installing: /usr/local/share/zsh/site-functions/_fastboot
-- Installing: /usr/local/bin/adb
-- Installing: /usr/local/bin/fastboot
-- Installing: /usr/local/bin/mke2fs.android
-- Installing: /usr/local/bin/simg2img
-- Installing: /usr/local/bin/img2simg
-- Installing: /usr/local/bin/append2simg
-- Installing: /usr/local/share/android-tools/completions/adb
-- Installing: /usr/local/share/android-tools/completions/fastboot
CMake Error at vendor/cmake_install.cmake:174 (file):
  file INSTALL cannot find
  "/__w/android-tools/android-tools/vendor/core/NOTICE": No such file or
  directory.
Call Stack (most recent call first):
  cmake_install.cmake:48 (include)

make: *** [Makefile:118: install] Error 1
Error: Process completed with exit code 2.```

Build fails in 31.0.3 in Musl target.

When I'm trying building in Gentoo Linux with Musl and Clang, I got this message:

In file included from /var/tmp/portage/portage/dev-util/android-tools-31.0.3/work/android-tools-31.0.3/vendor/e2fsprogs/contrib/android/e2fsdroid.c:8:

/var/tmp/portage/portage/dev-util/android-tools-31.0.3/work/android-tools-31.0.3/vendor/e2fsprogs/lib/ext2fs/ext2fs.h:1378:39: error: unknown type name 'dev_t'; did you mean 'div_t'?
extern char *ext2fs_find_block_device(dev_t device);
                                      ^~~~~
                                      div_t
/usr/include/stdlib.h:62:35: note: 'div_t' declared here
typedef struct { int quot, rem; } div_t;
                                  ^
In file included from /var/tmp/portage/portage/dev-util/android-tools-31.0.3/work/android-tools-31.0.3/vendor/e2fsprogs/contrib/android/e2fsdroid.c:8:
/var/tmp/portage/portage/dev-util/android-tools-31.0.3/work/android-tools-31.0.3/vendor/e2fsprogs/lib/ext2fs/ext2fs.h:1785:62: error: unknown type name 'mode_t'

This occurs because Musl have sys/types.h, but apparently doesn't declare HAVE_SYS_TYPES_H, so I set -DHAVE_SYS_TYPES_H=1 and build fine.

Update to Android 9

I am not sure if there are relevant changes, but to keep up with upstream it would probably make sense to rebase this on the latest Android version, right?

Possibly related: ADB sideloading doesn't work anymore in Alpine chroots, but it does work with the host system's fastboot version.

The disconnected/rebootable device does not disconnect and remains in the active list (no control of the "offline" status)

Hello. Thank you very much for your work, it is very necessary and useful. I really need your advice on the following issue...
I'm testing android-tools v31.0.0p1 on emulators vv5.1/9.0 from: https://osdn.net/projects/android-x86/releases

adb connect 192.168.0.80
connected to 192.168.0.80:5555
adb devices
List of devices attached
192.168.0.80:5555 device

adb shell reboot -p
... and here it continues to hang, and meanwhile the device is already turned off and, accordingly, does not accept any commands.

Tracking the offline status does not work when the device is rebooted or disconnected. Let me remind you that the normal shutdown/reboot of the device takes place in several stages...

For example - normal Shutdown:

  1. command: adb shell reboot -p
  2. Turning off the device
  3. The adb server shows the status "offline" (adb devices)
  4. After 1-2 minutes, the device that is already turned off leaves the list of connected devices

In versions 29.0.6, 30.0.5p1 & 31.0.0p1 (I didn't check the others) the disconnected device is permanently connected even after it is disconnected. Is this a bug?

I can't test it on a real device, there is no smartphone.
I apologize for my poor English, I communicate through an online translator.

p.s. for easy and quick control of the device behavior, you can use my ADBManager: https://github.com/AKotov-dev/adbmanager if compatible for you. It is under development, but it will speed up the process of testing android-tools in general.

Sincerely,
Alex

Issues with GCC 12.1

Hi

I need the following patch to compile with GCC 12.1

From 752fc3bd9a971858dbb7b51a0ef0289232e67e58 Mon Sep 17 00:00:00 2001
From: Mike Lothian <[email protected]>
Date: Sat, 14 May 2022 02:01:18 +0100
Subject: [PATCH] Add functional include

---
tls/include/adb/tls/tls_connection.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/tls/include/adb/tls/tls_connection.h
b/tls/include/adb/tls/tls_connection.h
index bc5b98ab..a112756c 100644
--- a/tls/include/adb/tls/tls_connection.h
+++ b/tls/include/adb/tls/tls_connection.h
@@ -19,6 +19,7 @@
#include <stddef.h>
#include <stdint.h>

+#include <functional>
#include <string_view>
#include <vector>

It also warns about:

 * QA Notice: Package triggers severe warnings which indicate that it
 *            may exhibit random runtime failures.
 * /var/tmp/portage/dev-util/android-tools-31.0.3_p1/work/android-tools-31.0.3p1/vendor/selinux/libselinux/src/label_file.h:289:25: warning: ‘free’ called on pointer ‘mmap_area_89->next_addr’ with nonzero offset 4 [-Wfree-nonheap-object]

Which is fixed with SELinuxProject/selinux@6e5d16a

build failure on archlinux , gcc 12

In file included from /home/ahmed/android-tools/vendor/adb/client/auth.cpp:35:
/home/ahmed/android-tools/vendor/adb/tls/include/adb/tls/tls_connection.h:51:31: error: ‘function’ in namespace ‘std’ does not name a template type
   51 |     using CertVerifyCb = std::function<int(X509_STORE_CTX*)>;
      |                               ^~~~~~~~
/home/ahmed/android-tools/vendor/adb/tls/include/adb/tls/tls_connection.h:27:1: note: ‘std::function’ is defined in header ‘<functional>’; did you forget to ‘#include <functional>’?
   26 | #include <openssl/ssl.h>
  +++ |+#include <functional>
   27 | #include <openssl/x509.h>
/home/ahmed/android-tools/vendor/adb/tls/include/adb/tls/tls_connection.h:52:28: error: ‘function’ in namespace ‘std’ does not name a template type
   52 |     using SetCertCb = std::function<int(SSL*)>;
      |                            ^~~~~~~~
/home/ahmed/android-tools/vendor/adb/tls/include/adb/tls/tls_connection.h:52:23: note: ‘std::function’ is defined in header ‘<functional>’; did you forget to ‘#include <functional>’?
   52 |     using SetCertCb = std::function<int(SSL*)>;
      |                       ^~~
/home/ahmed/android-tools/vendor/adb/tls/include/adb/tls/tls_connection.h:67:40: error: ‘CertVerifyCb’ has not been declared
   67 |     virtual void SetCertVerifyCallback(CertVerifyCb cb) = 0;
      |                                        ^~~~~~~~~~~~
/home/ahmed/android-tools/vendor/adb/tls/include/adb/tls/tls_connection.h:76:41: error: ‘SetCertCb’ has not been declared
   76 |     virtual void SetCertificateCallback(SetCertCb cb) = 0;
      |                                         ^~~~~~~~~
/home/ahmed/android-tools/vendor/adb/client/auth.cpp: In function ‘bool load_keys(const std::string&, bool)’:
/home/ahmed/android-tools/vendor/adb/client/auth.cpp:178:49: warning: ignoring attributes on template argument ‘int (*)(DIR*)’ [-Wignored-attributes]
  178 |         std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(path.c_str()), closedir);
      |                                                 ^
make[2]: *** [vendor/CMakeFiles/libadb.dir/build.make:150: vendor/CMakeFiles/libadb.dir/adb/client/auth.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:456: vendor/CMakeFiles/libadb.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

i'm using latest tarballs 31.0.3

Add aapt2. I need your help.

Hello. I am working on adding aapt2.
Now I have a successful build but I have an error while executing aapt2

./vendor/aapt2 version
Segmentation error (the memory stack is flushed to disk)

Next I used gdb --args ./vendor/aapt2 version

Program received signal SIGSEGV, Segmentation fault.
0x0000555555b4e12e in android::operator==<char> (lhs=<error reading variable: Cannot access memory at address 0x7fffff7feff8>, rhs=<error reading variable: Cannot access memory at address 0x7fffff7feff0>) at /home/5b/android-tools-31.0.3p1/vendor/base/libs/androidfw/include/androidfw/StringPiece.h:290
290	inline bool operator==(const ::std::basic_string<TChar>& lhs, const BasicStringPiece<TChar>& rhs) {

In build log I see this

In file included from /home/5b/android-tools-31.0.3p1/vendor/base/tools/aapt2/cmd/Command.h:26,
                 from /home/5b/android-tools-31.0.3p1/vendor/base/tools/aapt2/cmd/Command.cpp:17:
/home/5b/android-tools-31.0.3p1/vendor/base/libs/androidfw/include/androidfw/StringPiece.h: In instantiation of ‘bool android::operator==(const std::__cxx11::basic_string<_CharT>&, const android::BasicStringPiece<TChar>&) [with TChar = char]’:
/home/5b/android-tools-31.0.3p1/vendor/base/tools/aapt2/cmd/Command.cpp:191:34:   required from here
/home/5b/android-tools-31.0.3p1/vendor/base/libs/androidfw/include/androidfw/StringPiece.h:291:14: warning: in C++20 this comparison calls the current function recursively with reversed arguments
  291 |   return rhs == lhs;
      |          ~~~~^~~~~~

Mb you have secret knowledge, how can I fix this? =)

my aapt2 cmake file
#
# based on © 2022 Github Lzhiyong

protobuf_generate_cpp(AAPT2_CONFIGURATION_PROTO_SRCS AAPT2_CONFIGURATION_PROTO_HDRS base/tools/aapt2/Configuration.proto)
protobuf_generate_cpp(AAPT2_RESINT_PROTO_SRCS AAPT2_RESINT_PROTO_HDRS base/tools/aapt2/ResourcesInternal.proto)
protobuf_generate_cpp(AAPT2_RES_PROTO_SRCS AAPT2_RES_PROTO_HDRS base/tools/aapt2/Resources.proto)

# libincfs-utils
add_library(libincfs-utils STATIC
  incremental_delivery/incfs/util/map_ptr.cpp
)

target_include_directories(libincfs-utils PUBLIC
  core/include
  libbase/include
  incremental_delivery/incfs/include
  incremental_delivery/incfs/util/include
)

# libincfs
add_library(libincfs STATIC
  incremental_delivery/incfs/incfs_ndk.c
  incremental_delivery/incfs/incfs.cpp
  incremental_delivery/incfs/MountRegistry.cpp
  incremental_delivery/incfs/path.cpp
  incremental_delivery/sysprop/IncrementalProperties.sysprop.cpp
  )

target_include_directories(libincfs PUBLIC
  incremental_delivery/incfs/include
  incremental_delivery/incfs/util/include
  incremental_delivery/sysprop/include
  incremental_delivery/incfs/kernel-headers
  libbase/include
  libutils/include
  boringssl/include
  selinux/libselinux/include
  logging/liblog/include
)

# libbuildversion
add_library(libbuildversion STATIC
  libbuildversion/libbuildversion.cpp
  )

target_include_directories(libbuildversion PRIVATE
  libbuildversion/include
  )



set(INCLUDES
  base/tools/aapt2
  protobuf/src
  logging/liblog/include
  expat/lib
  fmtlib/include
  libpng
  libbase/include
  base/libs/androidfw/include
  base/cmds/idmap2/libidmap2_policies/include
  core/libsystem/include
  core/libutils/include
  boringssl/third_party/googletest/include
  libziparchive/include 
  libbuildversion/include
  incremental_delivery/incfs/util/include 
  incremental_delivery/incfs/kernel-headers
  native/include
  /usr/include/android/nativehelper
  )

set(COMPILE_FLAGS
  -Wno-missing-field-initializers
  -fno-exceptions 
  -fno-rtti
  -fPIC
  -DNDEBUG
  )

set(TOOL_SOURCE
  base/tools/aapt2/cmd/Command.cpp
  base/tools/aapt2/cmd/Compile.cpp
  base/tools/aapt2/cmd/Convert.cpp
  base/tools/aapt2/cmd/Diff.cpp
  base/tools/aapt2/cmd/Dump.cpp
  base/tools/aapt2/cmd/Link.cpp
  base/tools/aapt2/cmd/Optimize.cpp
  base/tools/aapt2/cmd/Util.cpp
  )
  
# build the host static library: aapt2
add_library(libaapt2 STATIC
  base/tools/aapt2/compile/IdAssigner.cpp
  base/tools/aapt2/compile/InlineXmlFormatParser.cpp
  base/tools/aapt2/compile/NinePatch.cpp
  base/tools/aapt2/compile/Png.cpp
  base/tools/aapt2/compile/PngChunkFilter.cpp
  base/tools/aapt2/compile/PngCrunch.cpp
  base/tools/aapt2/compile/PseudolocaleGenerator.cpp
  base/tools/aapt2/compile/Pseudolocalizer.cpp
  base/tools/aapt2/compile/XmlIdCollector.cpp
  base/tools/aapt2/configuration/ConfigurationParser.cpp
  base/tools/aapt2/dump/DumpManifest.cpp
  base/tools/aapt2/filter/AbiFilter.cpp
  base/tools/aapt2/filter/ConfigFilter.cpp
  base/tools/aapt2/format/Archive.cpp
  base/tools/aapt2/format/Container.cpp
  base/tools/aapt2/format/binary/BinaryResourceParser.cpp
  base/tools/aapt2/format/binary/ResChunkPullParser.cpp
  base/tools/aapt2/format/binary/TableFlattener.cpp
  base/tools/aapt2/format/binary/XmlFlattener.cpp
  base/tools/aapt2/format/proto/ProtoDeserialize.cpp
  base/tools/aapt2/format/proto/ProtoSerialize.cpp
  base/tools/aapt2/io/BigBufferStream.cpp
  base/tools/aapt2/io/File.cpp
  base/tools/aapt2/io/FileStream.cpp
  base/tools/aapt2/io/FileSystem.cpp
  base/tools/aapt2/io/StringStream.cpp
  base/tools/aapt2/io/Util.cpp
  base/tools/aapt2/io/ZipArchive.cpp
  base/tools/aapt2/link/AutoVersioner.cpp
  base/tools/aapt2/link/ManifestFixer.cpp
  base/tools/aapt2/link/NoDefaultResourceRemover.cpp
  base/tools/aapt2/link/ProductFilter.cpp
  base/tools/aapt2/link/PrivateAttributeMover.cpp
  base/tools/aapt2/link/ReferenceLinker.cpp
  base/tools/aapt2/link/ResourceExcluder.cpp
  base/tools/aapt2/link/TableMerger.cpp
  base/tools/aapt2/link/XmlCompatVersioner.cpp
  base/tools/aapt2/link/XmlNamespaceRemover.cpp
  base/tools/aapt2/link/XmlReferenceLinker.cpp
  base/tools/aapt2/optimize/MultiApkGenerator.cpp
  base/tools/aapt2/optimize/ResourceDeduper.cpp
  base/tools/aapt2/optimize/ResourceFilter.cpp
  base/tools/aapt2/optimize/ResourcePathShortener.cpp
  base/tools/aapt2/optimize/VersionCollapser.cpp
  base/tools/aapt2/process/SymbolTable.cpp
  base/tools/aapt2/split/TableSplitter.cpp
  base/tools/aapt2/text/Printer.cpp
  base/tools/aapt2/text/Unicode.cpp
  base/tools/aapt2/text/Utf8Iterator.cpp
  base/tools/aapt2/util/BigBuffer.cpp
  base/tools/aapt2/util/Files.cpp
  base/tools/aapt2/util/Util.cpp
  base/tools/aapt2/Debug.cpp
  base/tools/aapt2/DominatorTree.cpp
  base/tools/aapt2/java/AnnotationProcessor.cpp
  base/tools/aapt2/java/ClassDefinition.cpp
  base/tools/aapt2/java/JavaClassGenerator.cpp
  base/tools/aapt2/java/ManifestClassGenerator.cpp
  base/tools/aapt2/java/ProguardRules.cpp
  base/tools/aapt2/LoadedApk.cpp
  base/tools/aapt2/Resource.cpp
  base/tools/aapt2/ResourceParser.cpp
  base/tools/aapt2/ResourceTable.cpp
  base/tools/aapt2/ResourceUtils.cpp
  base/tools/aapt2/ResourceValues.cpp
  base/tools/aapt2/SdkConstants.cpp
  base/tools/aapt2/StringPool.cpp
  base/tools/aapt2/trace/TraceBuffer.cpp
  base/tools/aapt2/xml/XmlActionExecutor.cpp
  base/tools/aapt2/xml/XmlDom.cpp
  base/tools/aapt2/xml/XmlPullParser.cpp
  base/tools/aapt2/xml/XmlUtil.cpp
  base/tools/aapt2/Configuration.proto
  base/tools/aapt2/Resources.proto
  base/tools/aapt2/ResourcesInternal.proto
  ${AAPT2_CONFIGURATION_PROTO_SRCS} ${AAPT2_CONFIGURATION_PROTO_HDRS}
  ${AAPT2_RESINT_PROTO_SRCS} ${AAPT2_RESINT_PROTO_HDRS}
  ${AAPT2_RES_PROTO_SRCS} ${AAPT2_RES_PROTO_HDRS}
)
target_include_directories(libaapt2 PRIVATE ${INCLUDES})
target_compile_options(libaapt2 PRIVATE ${COMPILE_FLAGS})

# build the host shared library: aapt2_jni
add_library(libaapt2_jni SHARED
  base/tools/aapt2/jni/aapt2_jni.cpp
  ${TOOL_SOURCE}
  )
target_include_directories(libaapt2_jni PRIVATE ${INCLUDES})
target_compile_options(libaapt2_jni PRIVATE ${COMPILE_FLAGS})
target_link_libraries(libaapt2_jni libaapt2)

# build the executable file aapt2
add_executable(aapt2
  base/tools/aapt2/Main.cpp
  ${TOOL_SOURCE}
  )
target_include_directories(aapt2 PRIVATE ${INCLUDES})
target_compile_options(aapt2 PRIVATE ${COMPILE_FLAGS})
set_property(TARGET aapt2 PROPERTY CXX_STANDARD 17)
set_property(TARGET libaapt2_jni PROPERTY CXX_STANDARD 17)

target_link_libraries(aapt2
  libaapt2
  libincfs
  libandroidfw
  libutil
  liblog
  libincfs-utils
  libcutils
  libzip
  libbase
  libbuildversion
  png
  expat
  z
  protobuf
  )

adding d8?

how hard would it be to add d8? the upstream project requires depot-tools, which is quite sad...

Fastboot ends in "Segmentation Fault"

I have aarch64 android-tools in termux, and am having an issue where fastboot gives an error message saying "Segmentation Fault".
I have uninstalled and then reinstalled android-tools.

Android 10 : Motorola Moto E7 : aarch64 : Unrooted Stock rom
termux fboot err1
termux fboot err2
termux fboot err3

Failed to build with android ndk

Hi i tried to build adb, but get error as follow:

FAILED: vendor/CMakeFiles/libcutils.dir/core/libcutils/threads.cpp.o 
/Users/test/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android26 --gcc-toolchain=/Users/test/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64 --sysroot=/Users/test/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64/sysroot   -I../vendor/core/liblog/include -I../vendor/core/libutils/include -I../vendor/core/libcutils/include -I../vendor/core/base/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   -std=c++14 -Wno-attributes -D_FILE_OFFSET_BITS=64 -O2 -DNDEBUG  -fPIC   -std=gnu++14 -MD -MT vendor/CMakeFiles/libcutils.dir/core/libcutils/threads.cpp.o -MF vendor/CMakeFiles/libcutils.dir/core/libcutils/threads.cpp.o.d -o vendor/CMakeFiles/libcutils.dir/core/libcutils/threads.cpp.o -c ../vendor/core/libcutils/threads.cpp
../vendor/core/libcutils/threads.cpp:42:18: error: use of undeclared identifier '__NR_gettid'
  return syscall(__NR_gettid);
                 ^
1 error generated.
[12/318] Building CXX object vendor/CMakeFiles/libbase.dir/core/base/liblog_symbols.cpp.o
FAILED: vendor/CMakeFiles/libbase.dir/core/base/liblog_symbols.cpp.o 
/Users/test/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android26 --gcc-toolchain=/Users/test/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64 --sysroot=/Users/test/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64/sysroot   -I../vendor/core/base/include -I../vendor/core/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   -std=c++14 -Wno-attributes -D_FILE_OFFSET_BITS=64 -O2 -DNDEBUG  -fPIC   -std=gnu++14 -MD -MT vendor/CMakeFiles/libbase.dir/core/base/liblog_symbols.cpp.o -MF vendor/CMakeFiles/libbase.dir/core/base/liblog_symbols.cpp.o.d -o vendor/CMakeFiles/libbase.dir/core/base/liblog_symbols.cpp.o -c ../vendor/core/base/liblog_symbols.cpp
In file included from ../vendor/core/base/liblog_symbols.cpp:17:
../vendor/core/base/liblog_symbols.h:44:12: error: no template named 'optional' in namespace 'std'
const std::optional<LibLogFunctions>& GetLibLogFunctions();
      ~~~~~^
../vendor/core/base/liblog_symbols.cpp:28:12: error: no template named 'optional' in namespace 'std'
const std::optional<LibLogFunctions>& GetLibLogFunctions() {
      ~~~~~^
../vendor/core/base/liblog_symbols.cpp:29:15: error: no template named 'optional' in namespace 'std'
  static std::optional<LibLogFunctions> liblog_functions = []() -> std::optional<LibLogFunctions> {
         ~~~~~^
../vendor/core/base/liblog_symbols.cpp:29:73: error: no template named 'optional' in namespace 'std'
  static std::optional<LibLogFunctions> liblog_functions = []() -> std::optional<LibLogFunctions> {
                                                                   ~~~~~^
../vendor/core/base/liblog_symbols.cpp:56:12: error: no viable conversion from returned value of type 'android::base::LibLogFunctions' to function return type 'int'
    return real_liblog_functions;
           ^~~~~~~~~~~~~~~~~~~~~
5 errors generated.
[13/318] Building CXX object vendor/CMakeFiles/libcutils.dir/core/libcutils/android_get_control_file.cpp.o
FAILED: vendor/CMakeFiles/libcutils.dir/core/libcutils/android_get_control_file.cpp.o 
/Users/test/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android26 --gcc-toolchain=/Users/test/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64 --sysroot=/Users/test/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64/sysroot   -I../vendor/core/liblog/include -I../vendor/core/libutils/include -I../vendor/core/libcutils/include -I../vendor/core/base/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   -std=c++14 -Wno-attributes -D_FILE_OFFSET_BITS=64 -O2 -DNDEBUG  -fPIC   -std=gnu++14 -MD -MT vendor/CMakeFiles/libcutils.dir/core/libcutils/android_get_control_file.cpp.o -MF vendor/CMakeFiles/libcutils.dir/core/libcutils/android_get_control_file.cpp.o.d -o vendor/CMakeFiles/libcutils.dir/core/libcutils/android_get_control_file.cpp.o -c ../vendor/core/libcutils/android_get_control_file.cpp
In file included from ../vendor/core/libcutils/android_get_control_file.cpp:44:
In file included from ../vendor/core/base/include/android-base/file.h:26:
../vendor/core/base/include/android-base/unique_fd.h:59:9: error: use of undeclared identifier 'android_fdsan_exchange_owner_tag'
    if (android_fdsan_exchange_owner_tag) {
        ^
../vendor/core/base/include/android-base/unique_fd.h:60:26: error: use of undeclared identifier 'android_fdsan_create_owner_tag'
      uint64_t old_tag = android_fdsan_create_owner_tag(ANDROID_FDSAN_OWNER_TYPE_UNIQUE_FD,
                         ^
../vendor/core/base/include/android-base/unique_fd.h:62:26: error: use of undeclared identifier 'android_fdsan_create_owner_tag'
      uint64_t new_tag = android_fdsan_create_owner_tag(ANDROID_FDSAN_OWNER_TYPE_UNIQUE_FD,
                         ^
../vendor/core/base/include/android-base/unique_fd.h:64:7: error: use of undeclared identifier 'android_fdsan_exchange_owner_tag'
      android_fdsan_exchange_owner_tag(fd, old_tag, new_tag);
      ^
../vendor/core/base/include/android-base/unique_fd.h:68:9: error: use of undeclared identifier 'android_fdsan_close_with_tag'
    if (android_fdsan_close_with_tag) {
        ^
../vendor/core/base/include/android-base/unique_fd.h:69:22: error: use of undeclared identifier 'android_fdsan_create_owner_tag'
      uint64_t tag = android_fdsan_create_owner_tag(ANDROID_FDSAN_OWNER_TYPE_UNIQUE_FD,
                     ^
../vendor/core/base/include/android-base/unique_fd.h:71:7: error: use of undeclared identifier 'android_fdsan_close_with_tag'
      android_fdsan_close_with_tag(fd, tag);
      ^
7 errors generated.
[15/318] Building CXX object vendor/CMakeFiles/libbase.dir/core/base/file.cpp.o
FAILED: vendor/CMakeFiles/libbase.dir/core/base/file.cpp.o 
/Users/test/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android26 --gcc-toolchain=/Users/test/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64 --sysroot=/Users/test/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64/sysroot   -I../vendor/core/base/include -I../vendor/core/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   -std=c++14 -Wno-attributes -D_FILE_OFFSET_BITS=64 -O2 -DNDEBUG  -fPIC   -std=gnu++14 -MD -MT vendor/CMakeFiles/libbase.dir/core/base/file.cpp.o -MF vendor/CMakeFiles/libbase.dir/core/base/file.cpp.o.d -o vendor/CMakeFiles/libbase.dir/core/base/file.cpp.o -c ../vendor/core/base/file.cpp
In file included from ../vendor/core/base/file.cpp:17:
In file included from ../vendor/core/base/include/android-base/file.h:26:
../vendor/core/base/include/android-base/unique_fd.h:59:9: error: use of undeclared identifier 'android_fdsan_exchange_owner_tag'
    if (android_fdsan_exchange_owner_tag) {
        ^
../vendor/core/base/include/android-base/unique_fd.h:60:26: error: use of undeclared identifier 'android_fdsan_create_owner_tag'
      uint64_t old_tag = android_fdsan_create_owner_tag(ANDROID_FDSAN_OWNER_TYPE_UNIQUE_FD,
                         ^
../vendor/core/base/include/android-base/unique_fd.h:62:26: error: use of undeclared identifier 'android_fdsan_create_owner_tag'
      uint64_t new_tag = android_fdsan_create_owner_tag(ANDROID_FDSAN_OWNER_TYPE_UNIQUE_FD,
                         ^
../vendor/core/base/include/android-base/unique_fd.h:64:7: error: use of undeclared identifier 'android_fdsan_exchange_owner_tag'
      android_fdsan_exchange_owner_tag(fd, old_tag, new_tag);
      ^
../vendor/core/base/include/android-base/unique_fd.h:68:9: error: use of undeclared identifier 'android_fdsan_close_with_tag'
    if (android_fdsan_close_with_tag) {
        ^
../vendor/core/base/include/android-base/unique_fd.h:69:22: error: use of undeclared identifier 'android_fdsan_create_owner_tag'
      uint64_t tag = android_fdsan_create_owner_tag(ANDROID_FDSAN_OWNER_TYPE_UNIQUE_FD,
                     ^
../vendor/core/base/include/android-base/unique_fd.h:71:7: error: use of undeclared identifier 'android_fdsan_close_with_tag'
      android_fdsan_close_with_tag(fd, tag);
      ^
7 errors generated.
[18/318] Building CXX object vendor/CMakeFiles/libbase.dir/core/base/logging.cpp.o
FAILED: vendor/CMakeFiles/libbase.dir/core/base/logging.cpp.o 
/Users/test/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android26 --gcc-toolchain=/Users/test/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64 --sysroot=/Users/test/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64/sysroot   -I../vendor/core/base/include -I../vendor/core/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   -std=c++14 -Wno-attributes -D_FILE_OFFSET_BITS=64 -O2 -DNDEBUG  -fPIC   -std=gnu++14 -MD -MT vendor/CMakeFiles/libbase.dir/core/base/logging.cpp.o -MF vendor/CMakeFiles/libbase.dir/core/base/logging.cpp.o.d -o vendor/CMakeFiles/libbase.dir/core/base/logging.cpp.o -c ../vendor/core/base/logging.cpp
In file included from ../vendor/core/base/logging.cpp:58:
In file included from ../vendor/core/base/include/android-base/file.h:26:
../vendor/core/base/include/android-base/unique_fd.h:59:9: error: use of undeclared identifier 'android_fdsan_exchange_owner_tag'
    if (android_fdsan_exchange_owner_tag) {
        ^
../vendor/core/base/include/android-base/unique_fd.h:60:26: error: use of undeclared identifier 'android_fdsan_create_owner_tag'
      uint64_t old_tag = android_fdsan_create_owner_tag(ANDROID_FDSAN_OWNER_TYPE_UNIQUE_FD,
                         ^
../vendor/core/base/include/android-base/unique_fd.h:62:26: error: use of undeclared identifier 'android_fdsan_create_owner_tag'
      uint64_t new_tag = android_fdsan_create_owner_tag(ANDROID_FDSAN_OWNER_TYPE_UNIQUE_FD,
                         ^
../vendor/core/base/include/android-base/unique_fd.h:64:7: error: use of undeclared identifier 'android_fdsan_exchange_owner_tag'
      android_fdsan_exchange_owner_tag(fd, old_tag, new_tag);
      ^
../vendor/core/base/include/android-base/unique_fd.h:68:9: error: use of undeclared identifier 'android_fdsan_close_with_tag'
    if (android_fdsan_close_with_tag) {
        ^
../vendor/core/base/include/android-base/unique_fd.h:69:22: error: use of undeclared identifier 'android_fdsan_create_owner_tag'
      uint64_t tag = android_fdsan_create_owner_tag(ANDROID_FDSAN_OWNER_TYPE_UNIQUE_FD,
                     ^
../vendor/core/base/include/android-base/unique_fd.h:71:7: error: use of undeclared identifier 'android_fdsan_close_with_tag'
      android_fdsan_close_with_tag(fd, tag);
      ^
In file included from ../vendor/core/base/logging.cpp:64:
../vendor/core/base/liblog_symbols.h:44:12: error: no template named 'optional' in namespace 'std'
const std::optional<LibLogFunctions>& GetLibLogFunctions();
      ~~~~~^
../vendor/core/base/logging.cpp:73:10: error: use of undeclared identifier 'program_invocation_short_name'
  return program_invocation_short_name;
         ^
9 errors generated.

Add some other tools

Can you add some other tools like aapt2 aidl and so on, because I also made one like yours, sdk-tools including build-tools and platform-tools, but I think you do better

Synchronize git submodules automatically

I use a python script to shallow clone the git submodules manually. I wonder if it is possible to use GitHub Actions for that.

Click here to see the python script
#!/usr/bin/env python
# https://github.com/KuYaki/gitmodules/blob/master/gitmodules/gitmodules.py

"""
Clone a specific tag of git submodules with .gitmodules file
"""

import base64
import os
import sys
import subprocess
import requests

cwd = sys.path[0]
git_modules_file_path = os.path.join(cwd, ".gitmodules")
git_tag = "platform-tools-34.0.1"

if os.path.exists(git_modules_file_path):
    with open(git_modules_file_path) as f:
        path = None
        url = None
        for line in f.readlines():
            if "path = " in line:
                path = line.split("path = ")[-1][:-1]
            if "url = " in line:
                url = line.split("url = ")[-1][:-1]
            if path and url:
                if "boringssl" in path:
                    boring_url = f'https://android.googlesource.com/platform/external/boringssl/+/refs/tags/{git_tag}/BORINGSSL_REVISION?format=TEXT'
                    boring_sha = str(base64.b64decode(requests.get(boring_url, timeout=30).text), 'UTF-8').strip("\n")
                    print(f'git clone --filter=blob:none https://boringssl.googlesource.com/boringssl.git {path}')
                    subprocess.run(f'git clone --filter=blob:none https://boringssl.googlesource.com/boringssl.git {path}'.split(), check=True)
                    previous_dir = os.getcwd()
                    os.chdir(path)
                    print(f'git checkout {boring_sha}')
                    subprocess.run(f'git checkout {boring_sha}'.split(), check=True)
                    os.chdir(previous_dir)
                else:
                    print(f'git clone --depth=1 {url} {path} -b {git_tag}')
                    subprocess.run(f'git clone --depth=1 {url} {path} -b {git_tag}'.split(), check=True)
                path = None
                url = None

⚠️ Seek medical advice after seeing the python code.

  • What I can not do yet

    • Write correct python script.
    • Pass the submodules tag version to python script.
  • What I can try to do but need some guidance

    • Plug that python script in cmake with custom target.
    • Run that custom target in CI when invoked manually.
  • The plan

    • The python script will shallow clone each submodules using the .gitignore. The boringssl repository is an exception there as mentioned in cmake file.
    • After cloning, git diff --exit-code vendor command will check if there is any change.
    • If yes, tell developer to update submodules. Or CI can commit the changes when we become confident about that.
    • If there is no change in vendor directory, compile the project as usual.

Please share your ideas and thoughts about this.

vendor_kernel_boot partition is not known to fastboot

Using fastboot from this project (as packaged in Arch Linux's repos), I'm unable to update my Pixel 7:

$ fastboot update image-panther-tq1a.221205.011.zip
--------------------------------------------
Bootloader Version...: cloudripper-1.0-9231809
Baseband Version.....: g5300g-220923-221028-B-9229469
Serial Number........: 2A131FDH20093H
--------------------------------------------
extracting android-info.txt (0 MB) to RAM...
Checking 'product'                                 OKAY [  0.000s]
fastboot: error: device requires partition vendor_kernel_boot which is not known to this version of fastboot

But this works with the official version of fastboot, so it looks like a patch from upstream got missed somewhere. The release log says that support for this partition was added in 33.0.2. Here's the commit that added this.

Binaries in "vendor" folder

There are a lot of binaries and source code tarballs in the "vendor" folder. The idea is to build everything from source as I understand, so the binaries are not useful. Also they increase the download size quite a bit, the whole vendor folder of the latest release is over 400 MB in size.

Starting with 31.0.0 release golang needs Internet to build the project

We ship go.sum file since 31.0.0 release, which comes with following boringssl commit: https://boringssl-review.googlesource.com/c/boringssl/+/42044
Without Internet build now fails with

[ 50%] Generating err_data.c
cd /builddir/build/BUILD/android-tools-31.0.2/vendor/boringssl/crypto/err && /usr/bin/go run err_data_generate.go > /builddir/build/BUILD/android-tools-31.0.2/x86_64-redhat-linux-gnu/vendor/boringssl/crypto/err_data.c
go: golang.org/x/[email protected]: unrecognized import path "golang.org/x/crypto": https fetch: Get "https://golang.org/x/crypto?go-get=1": dial tcp: lookup golang.org: Temporary failure in name resolution

See full log: https://koji.fedoraproject.org/koji/taskinfo?taskID=73169944

lpmake --help segfaults

$ lpmake --help
zsh: segmentation fault  lpmake --help

I wonder if this is reproducible on other systems. This happens on gentoo with version 33.0.3. No crazy build options, everything up-to-date.
If not, I will eat my farts and dig deeper.

Darwin support

Trying to build on Darwin/macOS fails with this error:

...
[ 17%] Building CXX object vendor/CMakeFiles/libadb.dir/adb/services.cpp.o
[ 17%] Built target libandroidfw
[ 17%] Building CXX object vendor/CMakeFiles/libadb.dir/adb/socket_spec.cpp.o
[ 18%] Building CXX object vendor/CMakeFiles/libadb.dir/adb/sysdeps_unix.cpp.o
/tmp/nix-build-android-tools-31.0.3p1.drv-0/android-tools-31.0.3p1/vendor/adb/client/usb_linux.cpp:27:10: fatal error: 'linux/usb/ch9.h' file not found
#include <linux/usb/ch9.h>
         ^~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [vendor/CMakeFiles/libadb.dir/build.make:318: vendor/CMakeFiles/libadb.dir/adb/client/usb_linux.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 18%] Building CXX object vendor/CMakeFiles/libadb.dir/adb/sysdeps/errno.cpp.o
make[1]: *** [CMakeFiles/Makefile2:438: vendor/CMakeFiles/libadb.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

This sounds wrong to me as I shouldn't have to care about Linux-specific headers.

f2fs-tools patches

f2fs-tools is not available in android tools like make_f2fs, sload.

I'm trying to compile it but getting errors.

Armhf package ?

Hey, thank you for creating this repository.

I just upgraded one of my Docker container running Alpine and I realized there is no way I can install android-tools on my Raspberry pi... I understand supporting other arch is not in sight but could I find a armhf package anywhere ? I tried searching everywhere but without luck, are there any archives or anything else where I could find the package ?
Thank you so much in advance! 🙂

zsh completions are broken

Please don't install bash completion scripts to zsh. They don't work. Zsh itself already ships a _adb completion script which works great.

Broken by #23.

Build fails with "[Makefile:156: all] Error 2" on Ubuntu 22.04

I tried to build ADB on a docker image:

FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
    && apt-get install -y --no-install-recommends build-essential gdb wget tar xz-utils golang-go perl \
        ca-certificates liblz4-dev libbrotli-dev libpcre3 libpcre3-dev libzstd-dev libgtest-dev \
        libusb-1.0.0-dev protobuf-compiler libssl-dev libprotobuf-dev

RUN wget -q --show-progress --progress=bar https://cmake.org/files/v3.23/cmake-3.23.1.tar.gz \
    && tar -xvf cmake-3.23.1.tar.gz \
    && cd cmake-3.23.1 \
    && ./configure && make -j 12 && make install \
    && cd ..

ENV CFLAGS="-O0 -ggdb3 -fvar-tracking"
RUN wget -q --show-progress --progress=bar https://github.com/nmeum/android-tools/releases/download/31.0.3p1/android-tools-31.0.3p1.tar.xz \
    && tar -xvf android-tools-31.0.3p1.tar.xz
RUN mkdir android-tools-31.0.3p1/build && cd android-tools-31.0.3p1/build \
     && cmake .. && make -j 12 VERBOSE=1

CMD ["bash"]

but it results in error:

[ 20%] Linking CXX static library liblibadb.a
cd /android-tools-31.0.3p1/build/vendor && /usr/local/bin/cmake -P CMakeFiles/libadb.dir/cmake_clean_target.cmake
cd /android-tools-31.0.3p1/build/vendor && /usr/local/bin/cmake -E cmake_link_script CMakeFiles/libadb.dir/link.txt --verbose=1
/usr/bin/ar qc liblibadb.a CMakeFiles/libadb.dir/adb/client/adb_client.cpp.o CMakeFiles/libadb.dir/adb/client/adb_install.cpp.o CMakeFiles/libadb.dir/adb/client/adb_wifi.cpp.o CMakeFiles/libadb.dir/adb/client/auth.cpp.o CMakeFiles/libadb.dir/adb/client/bugreport.cpp.o CMakeFiles/libadb.dir/adb/client/commandline.cpp.o CMakeFiles/libadb.dir/adb/client/console.cpp.o CMakeFiles/libadb.dir/adb/client/file_sync_client.cpp.o CMakeFiles/libadb.dir/adb/client/incremental.cpp.o CMakeFiles/libadb.dir/adb/client/incremental_server.cpp.o CMakeFiles/libadb.dir/adb/client/incremental_utils.cpp.o CMakeFiles/libadb.dir/adb/client/line_printer.cpp.o CMakeFiles/libadb.dir/adb/client/main.cpp.o CMakeFiles/libadb.dir/adb/client/pairing/pairing_client.cpp.o CMakeFiles/libadb.dir/adb/client/usb_libusb.cpp.o CMakeFiles/libadb.dir/adb/client/usb_linux.cpp.o CMakeFiles/libadb.dir/adb/pairing_auth/aes_128_gcm.cpp.o CMakeFiles/libadb.dir/adb/pairing_auth/pairing_auth.cpp.o CMakeFiles/libadb.dir/adb/pairing_connection/pairing_connection.cpp.o CMakeFiles/libadb.dir/adb/services.cpp.o CMakeFiles/libadb.dir/adb/socket_spec.cpp.o CMakeFiles/libadb.dir/adb/sysdeps_unix.cpp.o CMakeFiles/libadb.dir/adb/sysdeps/errno.cpp.o CMakeFiles/libadb.dir/adb/sysdeps/posix/network.cpp.o CMakeFiles/libadb.dir/app_processes.pb.cc.o CMakeFiles/libadb.dir/adb_known_hosts.pb.cc.o CMakeFiles/libadb.dir/key_type.pb.cc.o CMakeFiles/libadb.dir/pairing.pb.cc.o
/usr/bin/ranlib liblibadb.a
make[2]: Leaving directory '/android-tools-31.0.3p1/build'
[ 20%] Built target libadb
make[1]: Leaving directory '/android-tools-31.0.3p1/build'
make: *** [Makefile:156: all] Error 2

it's at line $(MAKE) -f CMakeFiles/Makefile2 all of Makefile generated by CMake. Maybe this came from /usr/bin/ranlib liblibadb.a? I don't understand what this make error means.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.