在WayDroid中安装和运行Android应用

在完成了 安装Waydroid 之后,可以安装和运行Anroid应用。以下我的实践是安装和运行DingTalk

  • 首先检查waydroid状态:

    waydroid status
    

输出应该类似:

Session:        RUNNING
Container:      RUNNING
Vendor type:    MAINLINE
Session user:   huatai(1000)
Wayland display:        wayland-0

如果显示 session 没有运行:

Session:        STOPPED
Vendor type:    MAINLINE

则运行以下命令:

waydroid session start
  • 安装应用:

    waydroid app install xxxx.apk
    

同时错误:

[19:58:32] Failed to get service waydroidplatform, trying again...
[19:58:33] Failed to get service waydroidplatform, trying again...
...

按下 ctrl-c 可以看到报错实际上是 /usr/lib/waydroid/tools/interfaces/IPlatform.py

def get_service(args):
    helpers.drivers.loadBinderNodes(args)
    serviceManager = gbinder.ServiceManager("/dev/" + args.BINDER_DRIVER)
    tries = 1000

    remote, status = serviceManager.get_service_sync(SERVICE_NAME)
    while(not remote):
        if tries > 0:
            logging.warning(
                "Failed to get service {}, trying again...".format(SERVICE_NAME))
            time.sleep(1)
            remote, status = serviceManager.get_service_sync(SERVICE_NAME)
            tries = tries - 1
        else:
            return None

    return IPlatform(remote)

看来是检查 waydroidplatform 服务异常

排查

  • 执行 waydroid log 查看日至:

(003273) [00:34:14] Failed to add service waydroidhardware: -1
(003792) [00:34:15] Failed to start Clipboard manager service, check logs
(003792) [00:34:15] Failed to add service waydroidusermonitor: -1
lxc-start: waydroid: conf.c: run_buffer: 314 Script exited with status 126
lxc-start: waydroid: start.c: lxc_end: 958 Failed to run lxc.hook.post-stop for container "waydroid"
(003792) [00:35:40] Clipboard service is not even started
(003273) [00:35:41] session manager stopped, stopping container and waiting...
(003273) [00:35:41] WayDroid container is STOPPED
(003273) [00:35:41] % chmod 666 -R /dev/binder
(003273) [00:35:41] % chmod 666 -R /dev/vndbinder
(003273) [00:35:41] % chmod 666 -R /dev/hwbinder
(003273) [00:35:41] Container manager is waiting for session to load
(004510) [00:35:43] Save session config: /var/lib/waydroid/session.cfg
(004510) [00:35:43] UserMonitor service is not even started
(004510) [00:35:43] Clipboard service is not even started
(003273) [00:35:44] % /usr/lib/waydroid/data/scripts/waydroid-net.sh start
waydroid-net is already running
(003273) [00:35:44] % umount /var/lib/waydroid/rootfs/vendor/waydroid.prop
(003273) [00:35:44] % umount /var/lib/waydroid/rootfs/vendor
(003273) [00:35:44] % umount /var/lib/waydroid/rootfs
(003273) [00:35:44] % mount /var/lib/waydroid/images/system.img /var/lib/waydroid/rootfs
(003273) [00:35:44] % mount -o remount,ro /var/lib/waydroid/images/system.img /var/lib/waydroid/rootfs
(003273) [00:35:44] % mount /var/lib/waydroid/images/vendor.img /var/lib/waydroid/rootfs/vendor
(003273) [00:35:44] % mount -o remount,ro /var/lib/waydroid/images/vendor.img /var/lib/waydroid/rootfs/vendor
(003273) [00:35:44] % mount -o bind /var/lib/waydroid/waydroid.prop /var/lib/waydroid/rootfs/vendor/waydroid.prop
(003273) [00:35:44] % umount -l /sys/fs/cgroup/schedtune
umount: /sys/fs/cgroup/schedtune: no mount point specified.
(003273) [00:35:44] % chmod 777 -R /dev/ashmem
(003273) [00:35:44] % chmod 777 -R /dev/dri
(003273) [00:35:44] % chmod 777 -R /dev/fb0
(003273) [00:35:44] % chmod 777 -R /dev/video31
(003273) [00:35:44] % chmod 777 -R /dev/video18
(003273) [00:35:44] % chmod 777 -R /dev/video23
(003273) [00:35:44] % chmod 777 -R /dev/video22
(003273) [00:35:44] % chmod 777 -R /dev/video12
(003273) [00:35:44] % chmod 777 -R /dev/video11
(003273) [00:35:44] % chmod 777 -R /dev/video21
(003273) [00:35:44] % chmod 777 -R /dev/video10
(003273) [00:35:44] % chmod 777 -R /dev/video20
(003273) [00:35:44] % chmod 777 -R /dev/video16
(003273) [00:35:44] % chmod 777 -R /dev/video15
(003273) [00:35:44] % chmod 777 -R /dev/video14
(003273) [00:35:44] % chmod 777 -R /dev/video13
(003273) [00:35:44] % lxc-start -P /var/lib/waydroid/lxc -F -n waydroid -- /init
(003273) [00:35:44] New background process: pid=4548, output=background
(003273) [00:35:44] Save session config: /var/lib/waydroid/session.cfg
(004510) [00:35:44] Failed to start Clipboard manager service, check logs
(004510) [00:35:45] Failed to add service waydroidusermonitor: -1
(003273) [00:35:45] Failed to add service waydroidhardware: -1
lxc-start: waydroid: conf.c: run_buffer: 314 Script exited with status 126
lxc-start: waydroid: start.c: lxc_end: 958 Failed to run lxc.hook.post-stop for container "waydroid"
(005191) [00:36:56] Failed to get service waydroidplatform, trying again...
(005191) [00:36:57] Failed to get service waydroidplatform, trying again...
(005191) [00:36:58] Failed to get service waydroidplatform, trying again...
(005191) [00:36:59] Failed to get service waydroidplatform, trying again...
(005191) [00:37:00] Failed to get service waydroidplatform, trying again...
(005191) [00:37:01] Failed to get service waydroidplatform, trying again...
(007963) [00:54:58] Run waydroid -h for usage information.
(007992) [00:55:09] % tail -n 60 -F /var/lib/waydroid/waydroid.log
(007992) [00:55:09] *** output passed to waydroid stdout, not to this log ***

Failed to get service waydroidplatform, trying again… #282 的一个方法,似乎是 python gbinder 软件包的问题,通过最新的gbinder-python来修复:

sudo apt install devscripts dh-make

git clone --single-branch --branch bullseye https://github.com/erfanoabdi/gbinder-python.git
cd gbinder-python/
sudo apt build-dep .
dch --create --package "gbinder-python" --newversion "1.0.0~git20210909-1" foo bar
dh_make --createorig -p "gbinder-python_1.0.0~git20210909"
# Select "p" when prompted for the package type, leave the rest at the defaults
debuild -us -uc
cd ..
sudo dpkg -i python3-gbinder_1.0.0~git20210909-1_arm64.deb

但问题还是没有解决

参考

  • Mobian Wiki: Waydroid 这篇文档提供了源代码编译和软件仓库直接安装两种方法,并且给出了问题修复的很多方法,有参考价值