898 字
4 分钟
在 Fedora 38 上安装 Waydroid

Waydroid 介绍#

  • Waydroid 是一种基于容器的、能在常规的 GNU/Linux 系统上启动完整 Android 系统的方法。
  • Waydroid 不支持 NVIDIA 显卡(tegra 除外),需要运行在 Wayland 显示服务器下。
  • Waydroid 基于 LineageOS。

安装环境#

操作系统: Fedora 38 硬件配置: Intel ALder Lake I5-12500H 桌面环境: Gnome 44 Wayland 内核版本: 6.2.15-300.fc38.x86_64

安装#

Gnome 44 默认显示服务是 Wayland,如需切换注销选择显示服务登录。

命令行安装:

Terminal window
sudo dnf install waydroid
sudo systemctl enable --now waydroid-container

安装完成之后打开 waydroid 程序,在 OTA 文本框填入以下链接:

System OTA: https://ota.waydro.id/system Vendor OTA: https://ota.waydro.id/vendor

然后选择是否需要安装 OPENGAPPS ,点击下载按钮,等待镜像下载完成。 镜像下载完成之后会自动安装,镜像初始化完成后好像 waydroid 会自动启动(这里我忘记了。。。)

Waydroid 命令与使用#

启动容器#

Terminal window
sudo waydroid container start

开启 Waydroid#

Terminal window
waydroid session start

全屏模式#

Terminal window
waydroid show-full-ui

多窗口模式#

Terminal window
# 开启
waydroid prop set persist.waydroid.multi_windows true
# 关闭
waydroid prop set persist.waydroid.multi_windows false
sudo systemctl restart waydroid-container

设置宽高度#

Terminal window
waydroid prop set persist.waydroid.width 0-9999 (int) Used for user to override desired resolution
waydroid prop set persist.waydroid.height 0-9999 (int) Used for user to override desired resolution

Other Waydroid Prop Options#

Terminal window
waydroid prop set persist.waydroid.cursor_on_subsurface true/false (bool) Workaround for showing the cursor in multi_windows mode on some compositors
waydroid prop set persist.waydroid.invert_colors true/false (bool) Swaps the color space from RGBA to BGRA (only works with our patched mutter so far)
waydroid prop set persist.waydroid.height_padding 0-9999 (int) Adjust height padding
waydroid prop set persist.waydroid.width_padding 0-9999 (int) Adjust width padding
waydroid prop set persist.waydroid.suspend true/false (bool, default: true on kernel 4.9 and later) Let the Waydroid container sleep (after the display timeout) when no apps are active
waydroid prop set persist.waydroid.uevent true/false (bool, default: false) Allow android direct access to hotplugged devices
Modify app behaviour
waydroid prop set persist.waydroid.fake_touch (string, 91 character limit) Comma separated list of package names for which mouse inputs should be interpreted as touch inputs instead. Supports wildcards with *. For example, set this to "com.rovio.*" to match all games by Rovio.
waydroid prop set persist.waydroid.fake_wifi (string, 91 character limit) Comma separated list of package names for which the system will always appear as if connected to wifi. Supports wildcards with *. For example, set this to "com.gameloft.*" to match all games by Gameloft.

安装应用#

Terminal window
waydroid app install xxx.apk
#or
usage: waydroid app [-h] {install,remove,launch,intent,list} ...
options:
-h, --help show this help message and exit
subaction:
{install,remove,launch,intent,list}
install push a single package to the container and install it
remove remove single app package from the container
launch start single application
intent start single application
list list installed applications

安装自定义镜像#

将下载好的镜像放入目录:/usr/share/waydroid-extra/images/,然后运行:

Terminal window
waydroid init -f

使用 adb 连接调试#

使用命令:

Terminal window
waydroid status

显示如下:

Session: RUNNING
Container: RUNNING
Vendor type: MAINLINE
IP address: 192.168.240.112
Session user: encorexin(1000)
Wayland display: wayland-0

然后使用命令链接:

Terminal window
abd connect <ip>:5555

设置共享目录#

Terminal window
sudo mount --bind ~/Documents ~/.local/share/waydroid/data/media/0/Documents
sudo mount --bind ~/Downloads ~/.local/share/waydroid/data/media/0/Download
sudo mount --bind ~/Music ~/.local/share/waydroid/data/media/0/Music
sudo mount --bind ~/Pictures ~/.local/share/waydroid/data/media/0/Pictures
sudo mount --bind ~/Videos ~/.local/share/waydroid/data/media/0/Movies

使用脚本安装 Waydroid#

项目主页:https://github.com/ayasa520/waydroid_script

安装脚本#

Terminal window
sudo dnf install lzip
git clone https://github.com/ayasa520/waydroid_script.git
cd waydroid_script
sudo python3 -m pip install -r requirements.txt

使用#

Terminal window
sudo python3 main.py

选择需要安装的 Android 版本

选择需要操作

选择需要安装的应用

如果之前已经安装过 waydroid 了只需要安装后面的应用就行。

获取设备 id 并注册给谷歌#

使用命令进入 android shell:

Terminal window
sudo waydroid shell
ANDROID_RUNTIME_ROOT=/apex/com.android.runtime ANDROID_DATA=/data ANDROID_TZDATA_ROOT=/apex/com.android.tzdata ANDROID_I18N_ROOT=/apex/com.android.i18n sqlite3 /data/data/com.google.android.gsf/databases/gservices.db "select * from main where name = \"android_id\";"

然后会返回一段数据:android_id|* 星号为设备 id,是一串数字。

进入网址:https://www.google.com/android/uncertified,登录 Google 账号,将设备 id 复制到文本框内,点击注册等待半个小时然后重启 waydroid 就能在 waydroid 里面登录 Google Play 了。(需要将 waydroid 设备连接一次网络才能获取到设备 id,否则返回的内容为空。)

使用脚本获取:

Terminal window
sudo python3 main.py certified

至此,安装完成。

删除 Waydroid#

Terminal window
sudo dnf remove waydroid
sudo rm -rf /usr/bin/waydroid /var/lib/waydroid /home/.waydroid ~/waydroid ~/.share/waydroid ~/.local/share/applications/*aydroid* ~/.local/share/waydroid

参考资料#

在 Fedora 38 上安装 Waydroid
https://encorexin.online/posts/install-waydroid-on-fedora38/
作者
Encore Xin
发布于
2023-05-17
许可协议
CC BY-NC-SA 4.0

评论