获得root权限
在使用Android Studio的Emulator模拟器时,要获取root权限,只需要使用以下命令:
$ adb root
但是,有个前提是使用的镜像必须不带play标识的,因为带play标识的镜像是正式版,正式版不允许获得root
启用写入权限
1、使用以下命令查询模拟器名称
$ emulator -avd -list-avds
2、使用以下命令启动模拟器
$ emulator -avd "步骤1查询的模拟器名称" -writable-system
3、模拟器启动完成后,使用以下命令获得root权限
$ adb root
restarting adbd as root
4、接着执行命令
$ adb remount
Successfully disabled verity
virtual bool android::fiemap::ImageManagerBinder::MapImageDevice(const std::string &, const std::chrono::milliseconds &, std::string *) binder returned: Failed to map
[libfs_mgr] could not map scratch image
Failed to allocate scratch on /data, fallback to use free space on super
Using overlayfs for /system
Using overlayfs for /vendor
Using overlayfs for /product
Using overlayfs for /system_dlkm
Using overlayfs for /system_ext
Verity disabled; overlayfs enabled.
Now reboot your device for settings to take effect
5、然后执行命令,重启模拟器。模拟器重启完成后,再次获取root权限及挂载分区
$ adb reboot
$ adb root
$ adb remount
6、最后就可以向模拟器发送push命令,传送文件到system目录
$ adb push