Android7、8、9最新相關工具編譯彙總(adb.exe fastboot.exe)
1、SDK、adb、fastboot隨著版本迭代都有了一點變化,編譯以Android6.0為界
2、權威參考sdk/docs/howto_build_SDK.txt
3、adb windows版編譯方法:
make host_cross_adb
4、fastboot Windows版編譯方法:
make host_cross_fastboot
5、Android7.0編譯Android使用的adb
diff --git a/android/system/core/adb/Android.mk b/android/system/core/adb/Android.mk
index 62e6c28..428f70e 100755
--- a/android/system/core/adb/Android.mk
+++ b/android/system/core/adb/Android.mk
@@ -275,7 +275,7 @@ LOCAL_CFLAGS_darwin := \
$(ADB_COMMON_darwin_CFLAGS) \
-Wno-sizeof-pointer-memaccess -Wno-unused-parameter \
LOCAL_MODULE := adb
LOCAL_MODULE_TAGS := debug
LOCAL_MODULE_HOST_OS := darwin linux windows
@@ -378,3 +378,106 @@ LOCAL_STATIC_LIBRARIES += \
endif
include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libmyadb
+#LOCAL_MODULE_HOST_OS := darwin linux windows
+LOCAL_CFLAGS := $(LIBADB_CFLAGS) -DADB_HOST=1 \
+ -std=c++14 \
+ -Wexit-time-destructors \
+ -O2 \
+ -g \
+ -DADB_HOST_ON_TARGET=1 \
+ -Wall -Wno-unused-parameter -Werror \
+ -D_XOPEN_SOURCE \
+ -D_GNU_SOURCE
+
+LOCAL_SRC_FILES := \
+ $(LIBADB_SRC_FILES) \
+ adb_auth_host.cpp \
+ get_my_path_linux.cpp \
+ sysdeps_unix.cpp \
+ usb_linux.cpp \
+
+LOCAL_SANITIZE := $(adb_host_sanitize)
+# Even though we're building a static library (and thus there's no link step for
+# this to take effect), this adds the includes to our path.
+LOCAL_STATIC_LIBRARIES := libcrypto_static libbase
+
+LOCAL_MULTILIB := first //編譯平臺的位數控制,32,64
+include $(BUILD_STATIC_LIBRARY)
+include $(CLEAR_VARS)
+LOCAL_MODULE := libmydiagnose_usb
+
+LOCAL_CFLAGS := $(LIBADB_CFLAGS) -DADB_HOST_ON_TARGET=1
+LOCAL_SRC_FILES := diagnose_usb.cpp
+# Even though we're building a static library (and thus there's no link step for
+# this to take effect), this adds the includes to our path.
+LOCAL_STATIC_LIBRARIES := libbase
+include $(BUILD_STATIC_LIBRARY)
+
+# =========================================================
+include $(CLEAR_VARS)
+LOCAL_LDLIBS_linux := -lrt -ldl -lpthread
+
+LOCAL_SRC_FILES := \
+ adb_client.cpp \
+ bugreport.cpp \
+ client/main.cpp \
+ console.cpp \
+ commandline.cpp \
+ file_sync_client.cpp \
+ line_printer.cpp \
+ services.cpp \
+ shell_service_protocol.cpp \
+
+LOCAL_CFLAGS += \
+ $(ADB_COMMON_CFLAGS) \
+ -D_GNU_SOURCE \
+ -DADB_HOST=1 \
+ -std=c++14 \
+ -Wexit-time-destructors \
+ -DADB_HOST_ON_TARGET=1 \ //不加將不能啟動server
+LOCAL_CFLAGS += -Wno-error=non-virtual-dtor //忽略無虛解構函式錯誤
+LOCAL_CFLAGS_linux := \
+ $(ADB_COMMON_linux_CFLAGS) \
+LOCAL_MODULE := my_adb
+LOCAL_MODULE_TAGS := debug
+LOCAL_SANITIZE := $(adb_host_sanitize)
+LOCAL_STATIC_LIBRARIES := \
+ libmyadb \
+ libbase \
+ libcrypto_static \
+ libmydiagnose_usb \
+ liblog \
+ libcutils
+
+LOCAL_CXX_STL := libc++_static
+#LOCAL_LDLIBS= -lrt -ldl -lpthread
+LOCAL_SHARED_LIBRARIES :=
+include $(BUILD_EXECUTABLE)
diff --git a/android/system/core/adb/diagnose_usb.cpp b/android/system/core/adb/diagnose_usb.cpp
index 0f067b0..5ef8922 100755
--- a/android/system/core/adb/diagnose_usb.cpp
+++ b/android/system/core/adb/diagnose_usb.cpp
@@ -32,7 +32,7 @@ static const char kPermissionsHelpUrl[] = "http://developer.android.com/tools/de
// Returns a message describing any potential problems we find with udev, or nullptr if we can't
// find plugdev information (i.e. udev is not installed).
static const char* GetUdevProblem() {
-#if defined(__linux__)
+#if !defined(__linux__)
errno = 0;
group* plugdev_group = getgrnam("plugdev");
6、Android adb的system許可權使用者無法獲取usb裝置
修改system/core/./rootdir/ueventd.rc,加入
/dev/bus/usb/*/* 0777 root usb