Ubuntu 编译 Android userdebug

为了更好的动态调试apk,编译了一个userdebug版本AOSP,其boot.img 中的 ro.debuggable 为1,手机中的任何应用均可以调试

设备:nexus 5x

1. 确定aosp版本

5x最后支持的一个版本:
Nexus 5X binaries for Android 8.1.0 (OPM7.181205.001)

对应aosp分支 : android-8.1.0_r52

2. 准备源码与设备驱动

2.1 下载源码

proxychains4 repo init -u https://android.googlesource.com/platform/manifest -b android-8.1.0_r52
proxychains4 repo sync

2.2 下载驱动

Hardware ComponentCompanyDownload
Vendor image LG LinkLGlink
GPS, Audio, Camera, Gestures, Graphics, DRM, Video, SensorsQualcomlink

3. 编译

搭建编译环境

➜  android_8.1.0_r52 : source build/envsetup.sh
➜  android_8.1.0_r52 lunch

Lunch menu... pick a combo:
     1. aosp_arm-eng
     2. aosp_arm64-eng
     3. aosp_mips-eng
     4. aosp_mips64-eng
     5. aosp_x86-eng
     6. aosp_x86_64-eng
     7. full_fugu-userdebug
     8. aosp_fugu-userdebug
     9. aosp_car_emu_arm-userdebug
     10. aosp_car_emu_arm64-userdebug
     11. aosp_car_emu_x86-userdebug
     12. aosp_car_emu_x86_64-userdebug
     13. mini_emulator_arm64-userdebug
     14. m_e_arm-userdebug
     15. m_e_mips-userdebug
     16. m_e_mips64-eng
     17. mini_emulator_x86-userdebug
     18. mini_emulator_x86_64-userdebug
     19. uml-userdebug
     20. aosp_dragon-userdebug
     21. aosp_dragon-eng
     22. aosp_marlin-userdebug
     23. aosp_marlin_svelte-userdebug
     24. aosp_sailfish-userdebug
     25. aosp_walleye-userdebug
     26. aosp_walleye_test-userdebug
     27. aosp_taimen-userdebug
     28. aosp_angler-userdebug
     29. aosp_bullhead-userdebug
     30. aosp_bullhead_svelte-userdebug
     31. hikey-userdebug
     32. hikey960-userdebug

Which would you like? 29
➜  android_8.1.0_r52 : export LC_ALL=C
➜  android_8.1.0_r52 : m

4. 刷入设备

➜  bullhead : pwd
/Volumes/source/aosp/android_8.1.0_r52/out/target/product/bullhead
➜  bullhead : export ANDROID_PRODUCT_OUT=`pwd`
➜  bullhead : adb reboot bootloader
➜  bullhead fastboot -w flashall
--------------------------------------------
Bootloader Version...: BHZ32c
Baseband Version.....: M8994F-2.6.42.5.03
Serial Number........: 025eb2d09e8db764
--------------------------------------------
Checking 'product'                                 OKAY [  0.020s]
Sending 'boot' (11785 KB)                          OKAY [  0.366s]
Writing 'boot'                                     OKAY [  0.107s]
Sending 'recovery' (17429 KB)                      OKAY [  0.503s]
Writing 'recovery'                                 OKAY [  0.214s]
Sending sparse 'system' 1/2 (524276 KB)            OKAY [ 13.281s]
Writing 'system'                                   OKAY [  6.104s]
Sending sparse 'system' 2/2 (496562 KB)            OKAY [ 13.197s]
Writing 'system'                                   OKAY [  6.887s]
Sending 'vendor' (185543 KB)                       OKAY [  4.683s]
Writing 'vendor'                                   OKAY [  2.447s]
Erasing 'userdata'                                 OKAY [  2.582s]
mke2fs 1.44.4 (18-Aug-2018)
Creating filesystem with 6661115 4k blocks and 1667904 inodes
Filesystem UUID: 7c46210d-e4c9-4f38-8dce-9e11ac137a84
Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
    4096000

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

Sending 'userdata' (4272 KB)                       OKAY [  0.189s]
Writing 'userdata'                                 OKAY [  0.065s]
Erasing 'cache'                                    OKAY [  0.086s]
mke2fs 1.44.4 (18-Aug-2018)
Creating filesystem with 24576 4k blocks and 24576 inodes

Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done

Sending 'cache' (68 KB)                            OKAY [  0.080s]
Writing 'cache'                                    OKAY [  0.021s]
Rebooting                                          OKAY [  0.020s]
Finished. Total time: 51.816s

hint: 开机后系统出现“There’s an internal problem with your device”的警告,查了一波,发现问题不大,系统并没有实质性的问题。

Google added a check which compares /system/build.prop with the /vendor/build.prop, if they don’t match, the error is shown.

具体查看How to Fix “There’s an internal problem with your device” error on Nexus 9


参考文章:

  1. 在Ubuntu 18.04上建置AOSP編譯環境
  2. 记一次安卓系统源码编译刷机过程

添加新评论

请不要水评论

评论列表