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-tools
package 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
bridged
mode)
-
In terminal emulator (in the VM), run
ip a
and note the IP address of the virtual network adapter. It's usually the last one in the list. It's namedeth0
on my VM.
It must be in the same subnet as the host (i.e. host IP is192.168.0.2
and Android-x86 VM IP is192.168.0.3
). -
Change the IP address in the
Adb Push.sh
script @line 1 to the one you just noted. -
Put any files you wish to send to the Android-x86 VM in the
Transfers
folder. Feel free to delete the.gitkeep
file while at it. -
Run the
Adb Push.sh
script. -
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.sh
script @line 1 to the one from step 1. -
Put any files you wish to send back to the host in a directory named
out
under/sdcard/Transfers/
(you'll probably need to create it). -
Run the
Adb Pull.sh
script in the host. -
Find your newly pulled files in the
Transfers/out
directory.
-
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 thermacvlan
script 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-server
in the host. -
Two additional scripts are provided for convenience:
rip
andrrscan
. Those are intended to be copied to and used from the Android-x86 virtual machine. I recommend placing them under/system/sbin
so 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
.
-
rip
is used to add a predefined IP address to the VM's network interface so that you won't have to edit yourAdb Pull.sh
andAdb Push.sh
everytime. It must be run before running either script in the host. -
rrscan
is 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 push
from theAdb Push.sh
script, and this eliminates the need for therrscan
script. But I haven't tested.)
Please open an issue and I'll try my best to help you.