Share files between your PC and an Android-x86 virtual machine.
Note: Assumes a GNU/Linux operating system. Mostly portable, though I don't have the time to port it myself ATM.
- Android Debug Bridge (adb) - https://developer.android.com/studio/command-line/adb
(part ofandroid-toolspackage in Arch Linux)
- A terminal emulator (the official Android-x86 release already includes the one from https://play.google.com/store/apps/details?id=jackpal.androidterm if I'm not mistaken)
- Root access
- Network connectivity between guest and host (in virt-manager the network interface must be in
bridgedmode)
-
In terminal emulator (in the VM), run
ip aand note the IP address of the virtual network adapter. It's usually the last one in the list. It's namedeth0on my VM.
It must be in the same subnet as the host (i.e. host IP is192.168.0.2and Android-x86 VM IP is192.168.0.3). -
Change the IP address in the
Adb Push.shscript @line 1 to the one you just noted. -
Put any files you wish to send to the Android-x86 VM in the
Transfersfolder. Feel free to delete the.gitkeepfile while at it. -
Run the
Adb Push.shscript. -
In the Android VM, browse to /sdcard/Transfers and find your newly pushed files.
-
(Follow step 1 from instructions above)
-
Change the IP address in the
Adb Pull.shscript @line 1 to the one from step 1. -
Put any files you wish to send back to the host in a directory named
outunder/sdcard/Transfers/(you'll probably need to create it). -
Run the
Adb Pull.shscript in the host. -
Find your newly pulled files in the
Transfers/outdirectory.
-
If you see:
unable to connect to 192.168.0.8:5555: No route to host
adb: error: failed to get feature set: no devices/emulators foundthen there is no connectivity to the VM.
If you indeed are using QEMU-KVM (possibly with
virt-manager), I have thermacvlanscript to aid in getting virtual machines to talk to the host via network. -
The first time you run either script, you should expect to see:
- daemon not running; starting now at tcp:5037
- daemon started successfully
After that, all further runs will show:
already connected to [ip:port]
This is normal and expected. If, for any reason, the scripts stops working after rebooting the VM, you may get around that by running
adb kill-serverin the host. -
Two additional scripts are provided for convenience:
ripandrrscan. Those are intended to be copied to and used from the Android-x86 virtual machine. I recommend placing them under/system/sbinso that they can be called anytime from the terminal emulator right after executingsu. Make sure they are executable, i.e.chmod u+x rip|chmod u+x rscan.
-
ripis used to add a predefined IP address to the VM's network interface so that you won't have to edit yourAdb Pull.shandAdb Push.sheverytime. It must be run before running either script in the host. -
rrscanis useful to get your recently pushed media to be recognized by media applications (e.g. photos will appear in the gallery without having to reboot.) This script should be run after pushing files.
(Note: it is probably possible to runadb shell "su -c 'am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///mnt/sdcard'"right afteradb pushfrom theAdb Push.shscript, and this eliminates the need for therrscanscript. But I haven't tested.)
Please open an issue and I'll try my best to help you.