Search code examples
androidandroid-emulatoradb

How to copy a file to Android's /system folder


I am running Android emulator (emulator version 30.5.5.0) and the avd: Pixel_3a_API_30_x86 from AndroidStudio. Using adb.exe (Android Debug Bridge) I try to copy a file from the Windows host to the emulated Android /system/... folder, but I haven't been able to after trying different things like this tutorial:

  • I run the android emulator from the command line to specify the parameter -writable-system:
cd C:\Users\%username%\AppData\Local\Android\Sdk\emulator
emulator -avd Pixel_3a_API_30_x86 -writable-system

Then from another command-line window while the emulator is running:

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

Then I get the error: ERROR:

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

How can I copy the file from Windows to Android /system ?


Solution

  • The tutorial in the link was missing some commands and the web page was not updated with the latest version from GitHub.

    Here is the final sequence (for API LEVEL > 28):

    adb root
    adb shell avbctl disable-verification
    adb reboot
    adb root
    adb remount
    
    adb push MyFile.txt /system/etc/security/cacerts