如何将文件复制到 Android 的 /system 文件夹

Laz*_*aro 0 android adb android-emulator

我正在运行 Android 模拟器(模拟器版本 30.5.5.0)和 avd:Pixel_3a_API_30_x86来自 AndroidStudio。使用adb.exe(Android 调试桥),我尝试将文件从 Windows 主机复制到模拟的 Android文件夹,但在尝试了本教程/system/...等不同操作后,我无法做到这一点:

  • 我从命令行运行 android 模拟器来指定参数-writable-system:
cd C:\Users\%username%\AppData\Local\Android\Sdk\emulator
emulator -avd Pixel_3a_API_30_x86 -writable-system
Run Code Online (Sandbox Code Playgroud)

然后在模拟器运行时从另一个命令行窗口:

cd C:\Users\%username%\AppData\Local\Android\Sdk\platform-tools

adb root
adb shell "mount -o rw,remount /"
'/dev/block/dm-0' is read-only

adb push MyFile.txt /system/etc/security/cacerts
Run Code Online (Sandbox Code Playgroud)

然后我收到错误:错误:

MyFile.txt: 1 file pushed, 0 skipped. 0.1 MB/s (950 bytes in 0.011s)
adb: error: failed to copy 'MyFile.txt' to '/system/etc/security/cacerts/MyFile.txt': remote couldn't create file: Read-only file system
Run Code Online (Sandbox Code Playgroud)

如何将文件从 Windows 复制到 Android /system?

Laz*_*aro 6

链接中的教程缺少一些命令,并且网页未使用GitHub 的最新版本进行更新。

以下是最终序列(对于 API LEVEL > 28):

adb root
adb shell avbctl disable-verification
adb reboot
adb root
adb remount

adb push MyFile.txt /system/etc/security/cacerts
Run Code Online (Sandbox Code Playgroud)