1.安裝虛擬機(jī)
略
2.安裝waydroid
Ubuntu/Debian and derivatives
For Droidian and Ubuntu Touch, skip directly to the last step
-
Install pre-requisites
sudo apt install curl ca-certificates -y
-
Add the official repository
curl https://repo.waydro.id | sudo bash
If the script fails to detect your distribution, you can provide a valid option by appending
-s <DISTRO>
. Currently supported values are: focal, jammy, kinetic, lunar, mantic, bookworm, bullseye, sid
-
Install waydroid
sudo apt install waydroid -y
Then start Waydroid from the applications menu.
?3.如何使用
1. 啟動(dòng)container
sudo waydroid container start
2. 新開一個(gè)終端,創(chuàng)建一個(gè)session(不要使用sudo)
waydroid session start
出現(xiàn)如下輸出說明啟動(dòng)成功
"Android with user 0 is ready"
3. 全屏模式啟動(dòng)Waydroid
waydroid show-full-ui
4.可能遇到的問題
問題 1:如果是mobaxterm啟動(dòng),可能會(huì)有如下問題
如果沒有啟動(dòng) session ,會(huì)有如下報(bào)錯(cuò):
/home/yk# waydroid app install app-debug.apk
[16:15:09] WayDroid session is stopped
waydroid對(duì)于桌面協(xié)議有要求,只能是wayland,不能是 tty 和 x11,如果配置不當(dāng)會(huì)出現(xiàn)如下錯(cuò)誤:
ERROR: org.freedesktop.DBus.Error.Spawn.ExecFailed: /usr/bin/dbus-launch terminated abnormally with the following error: MoTTY X11 proxy: Unsupported authorisation protocol
Autolaunch error: X11 initialization failed.
?ERROR: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
更多類似問題:WAYLAND_DISPLAY is not set, defaulting to "wayland-0" · Issue #771 · waydroid/waydroid · GitHub
解決方法 :
建議使用weston來啟動(dòng)waydroid。
- 安裝
sudo apt install weston
- 啟動(dòng),可以在tty終端中啟動(dòng),比如MobaxTerm
weston
- 在彈出界面中點(diǎn)擊左上角的terminal圖標(biāo)開啟一個(gè)命令行終端
- 啟動(dòng)session,只需要啟動(dòng)一次
waydroid session start
- 開啟lineageOS桌面
waydroid show-full-ui
- lineageOS的左上角也有terminal啟動(dòng)圖標(biāo),點(diǎn)擊后安裝apk
waydroid app install app.apk
- adb連接waydroid android虛擬機(jī)
Grab waydroid IP address from Android Settings-> About
And start adb:
adb connect <IP>:5555
如果需要開發(fā)者權(quán)限,連續(xù)點(diǎn)擊?setting->About->Build Num
問題2 :虛擬機(jī)使用 waydroid show-full-ui 沒反應(yīng)
如果使用虛擬機(jī)運(yùn)行Waydroid或者是 Nvidia 顯卡,則會(huì)出現(xiàn) waydroid無法啟動(dòng)。
解決方法 :
You can force Waydroid to run without GPU acceleration by modifying the waydroid configuration file:
nano /var/lib/waydroid/waydroid.cfg
Add the following lines in the [properties]
section:
ro.hardware.gralloc=default
ro.hardware.egl=swiftshader
Apply the configuration with:
sudo waydroid upgrade -o
?5.下載waydoird 對(duì)應(yīng)的 lineage 源碼&&編譯 lineage 源碼
1. 同步倉庫:
repo init -u https://github.com/LineageOS/android.git -b lineage-18.1 --git-lfs
repo sync build/make
可能需要安裝的rpm包有:
git-lfs
2.下載 local_manifests
wget -O - https://raw.githubusercontent.com/waydroid/android_vendor_waydroid/lineage-18.1/manifest_scripts/generate-manifest.sh | bash
3. 下載源碼,這步可能會(huì)要持續(xù)很久
Then to sync up:
repo sync
4. 打Waydroid的最新補(bǔ)丁
After that is complete, we apply the Waydroid patches:
apply-waydroid-patches
5. 開始編譯
Please see the LineageOS Wiki for building environment setup.
5.1 Waydroid Build Commands:
. build/envsetup.sh
5.2 lunch
這一步一定要選對(duì),因?yàn)橄乱徊骄幾g會(huì)持續(xù)很久,選錯(cuò)了就浪費(fèi)很多時(shí)間
arm架構(gòu)
lunch lineage_waydroid_arm-userdebug
lunch lineage_waydroid_arm64-userdebug
x86架構(gòu)
lunch lineage_waydroid_x86-userdebug
lunch lineage_waydroid_x86_64-userdebug
5.3 開始編譯
make systemimage -j$(nproc --all)
make vendorimage -j$(nproc --all)
5.4 轉(zhuǎn)換鏡像為可以燒錄的文件
Image Generation From Sparse Image:
The default output of the AOSP build system is an "Android Sparse Image". We need raw fileystems instead. From the same terminal where you just built a system and a vendor image, run:
simg2img $OUT/system.img ~/system.img
simg2img $OUT/vendor.img ~/vendor.img
to obtain your target raw images at ~/system.img and ~/vendor.img
6. 可能遇到的問題
Local Manifest:
To manually regenerate the local_manifests, we also have added a function to do so
waydroid-generate-manifest
After doing that you will want to resync (this will wipe out any local changes, so make sure you save your work to a different branch)
參考:
Compile Waydroid - Lineage OS based images - Waydroidhttps://docs.waydro.id/development/compile-waydroid-lineage-os-based-images#how-to-build
6.替換自己編譯的 lineage 鏡像,替換原有 waydroid 默認(rèn)android 鏡像
6.1 創(chuàng)建鏡像啟動(dòng)路徑
sudo mkdir -p /etc/waydroid-extra/images
6.2 使用第五步編譯好的鏡像文件
cp vendor.img?/etc/waydroid-extra/images
cp system.img?/etc/waydroid-extra/images
注意:
waydroid --version
1.3.3之前的版本,鏡像存放路徑為/usr/share/waydroid-extra/images/
6.2 使用第三方編譯好的鏡像文件
?download the images (e.g. x86_64 gapps system and mainline vendor) manually from sourceforge?
sudo unzip lineage-*-system.zip -d /etc/waydroid-extra/images
sudo unzip lineage-*-vendor.zip -d /etc/waydroid-extra/images
rm lineage-*-system.zip lineage-*-vendor.zip
6.3 重新加載鏡像
sudo waydroid init -f文章來源:http://www.zghlxwxcb.cn/news/detail-848725.html
參考:Using custom Waydroid images - Waydroidhttps://docs.waydro.id/faq/using-custom-waydroid-images文章來源地址http://www.zghlxwxcb.cn/news/detail-848725.html
7. LineageOS 和 AOSP 版本對(duì)應(yīng)關(guān)系
Version | AOSP version | Last build release date |
---|---|---|
18.1 | 11?(Red Velvet Cake) | (Current) |
19.1 | 12.1?(Snow Cone) | (Current) |
20 | 13?(Tiramisu) | (Current) |
到了這里,關(guān)于[Android] ubuntu虛擬機(jī)上搭建 Waydroid 環(huán)境的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!