Skip to content

Instantly share code, notes, and snippets.

@diyism
Last active December 18, 2023 07:49
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diyism/70ae5719d42db173e0da0742f2728cda to your computer and use it in GitHub Desktop.
Save diyism/70ae5719d42db173e0da0742f2728cda to your computer and use it in GitHub Desktop.
waydroid on debian x64 and armbian focal pine64
============================x64 debian=====================================
# upgrade kali linux kernel from 5.7 to 5.9+(download from: http://old.kali.org/kali/pool/main/l/linux/)
# sudo apt install linux-image-6.3.0-kali1-amd64
# in live iso: sudo /usr/sbin/update-initramfs.orig.initramfs-tools -c -k 6.3.0-kali1-amd64
$ sudo dpkg -i linux-image-5.9.0-kali1-amd64_5.9.1-1kali2_amd64
# install header file(download from: https://http.kali.org/kali/pool/main/l/linux/):
$ sudo dpkg -i linux-kbuild-5.9_5.9.1-1kali2_amd64.deb linux-headers-5.9.0-kali1-common_5.9.1-1kali2_all.deb linux-headers-5.9.0-kali1-amd64_5.9.1-1kali2_amd64.deb
$ git clone https://github.com/diyism/anbox-modules.git
$ cd anbox-modules
$ sudo ./INSTALL.sh
#reboot
#don't need to add binder.devices=binder,hwbinder,vndbinder,anbox-binder,anbox-hwbinder,anbox-vndbinder to grub boot parameters
$ dkms status
anbox-ashmem, 1, 5.9.0-kali1-amd64, x86_64: installed (original_module exists)
anbox-binder, 1, 5.9.0-kali1-amd64, x86_64: installed (original_module exists)
$ sudo waydroid init #download lineage image
$ XDG_SESSION_TYPE=wayland weston
# in weston:
$ sudo nohup waydroid container restart >/dev/null 2>&1 &
$ waydroid session start
$ waydroid status
Session: RUNNING
Container: RUNNING
Vendor type: MAINLINE
Session user: malcolm(1000)
Wayland display: wayland-0
$ tail -f /var/lib/waydroid/waydroid.log
(687291) [20:46:03] Failed to start Clipboard manager service, check logs
(687291) [20:46:03] Failed to add service waydroidusermonitor: -1
(685184) [20:46:04] Failed to add service waydroidhardware: -1
$ waydroid show-full-ui
[11:02:41] Failed to get service waydroidplatform, trying again...
[11:02:42] Failed to get service waydroidplatform, trying again...
#need to wait for about 1 minute for "waydroidplatform error" stop repeating
$ nano /etc/gbinder.conf
[General]
ApiLevel = 29
$ waydroid session start
[20:46:03] Failed to start Clipboard manager service, check logs
[20:47:00] Android with user 0 is ready
$ waydroid app list
Name: Files
packageName: com.android.documentsui
categories:
android.intent.category.LAUNCHER
Name: Contacts
packageName: com.android.contacts
categories:
android.intent.category.LAUNCHER
$ waydroid app install 1.apk
$ sudo waydroid shell
reboot
# if "sudo waydroid container start" shows error "mount: /var/lib/waydroid/rootfs: /dev/loopN already mounted or mount point busy."
# then try:
$ sudo umount /var/lib/waydroid/rootfs
$ sudo losetup -d /dev/loopN
$ lsof | grep loopN
$ fuser -k /dev/loopN
$ losetup -a | grep waydroid
$ rm /dev/loopN
# if everything is ok, then do this in weston:
while true; do nohup waydroid session start > /dev/null 2>&1; sleep 1; done &
# install libhoudini arm64 translation and open google gapps:
# https://forum.zorin.com/t/guide-for-android-emulation-with-arm64-translation/12852#arm-translation-5
$ sudo apt install lzip
$ git clone --depth=1 https://github.com/casualsnek/waydroid_script
$ cd waydroid_script
$ sudo python3 -m pip install -r requirements.txt
$ sudo waydroid container stop
$ sudo python3 main.py certified
# you can see the gsf id, or in shelter work profile use "device id(onemlab.deviceid)" app to show gsf id
# register your gsf id into google server: https://google.com/android/uncertified/?pli=1 wait for 20 mins and clear play store service cache(settings/storage/other apps) if you haved installed play store
$ sudo python3 waydroid_extras.py -g
# sublime-text will automatically try xwayland mode and launched into weston window (wayland android in it)
# to avoid thus, I need to modify "subl" short command:
$ cat /usr/bin/subl
#!/bin/sh
GDK_BACKEND=x11 exec /opt/sublime_text/sublime_text --fwdargv0 "$0" "$@"
#or when boot weston, rename weston socket name:
XDG_SESSION_TYPE=wayland weston --socket=mysocket
============================pine64 armbian=====================================
#download armbian focal image(withoud desktop) from https://www.armbian.com/pine64/#kernels-archive-all
#download https://redirect.armbian.com/pine64/Focal_current
$ wget https://mirrors.nju.edu.cn/armbian-releases/pine64/archive/Armbian_22.05.3_Pine64_focal_current_5.15.48.img.xz
#burn Armbian_22.05.3_Pine64_focal_current_5.15.48.img.xz into sd card with bztsrc/usbimager (https://gitlab.com/bztsrc/usbimager)
#insert sd card into pine64 single board and boot it
#set root passsword, user password
$ sudo su
$ apt update
$ apt install gnome-session-wayland #for chinese: apt install --no-install-recommends ibus-pinyin ibus ibus-gtk3 fonts-wqy-microhei
$ apt install gnome-terminal
$ apt install gdm3 #apt remove lightdm xfce4
$ nano /etc/gdm3/custom.conf #ensure WaylandEnable=false is commented, and autologin is not commented
#WaylandEnable=false
AutomaticLoginEnable = true
AutomaticLogin = malcolm
$ nano /usr/lib/udev/rules.d/61-gdm.rules #comment all lines
//$ sed -i "s/# sleep-inactive-ac-type='suspend'/sleep-inactive-ac-type='nothing'/" /etc/gdm3/greeter.dconf-defaults
//$ sed -i "s/# sleep-inactive-ac-timeout=1200/sleep-inactive-ac-timeout=0/" /etc/gdm3/greeter.dconf-defaults
//$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type nothing
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 0
$ gsettings set org.gnome.desktop.session idle-delay 0
# if "sleep-inactive-ac-timeout"(20 minutes) and "idle-delay"(5 minutes) doesn't take effect(power off after 20 minutes),
# to use "gnome-session-inhibit top" to prevent logout/sleep/suspension
$ systemctl restart gdm3
$ echo $XDG_SESSION_TYPE #it still shows tty
$ reboot
$ echo $XDG_SESSION_TYPE #now it shows wayland
$ apt install linux-headers-current-sunxi64
$ git clone https://github.com/choff/anbox-modules.git
$ cd anbox-modules
$ ./INSTALL.sh
...
DKMS: install completed.
binder_linux 122880 0
ashmem_linux 24576 0
#export DISTRO="focal" && \
#curl https://repo.waydro.id/waydroid.gpg --output /usr/share/keyrings/waydroid.gpg && \
#echo "deb [signed-by=/usr/share/keyrings/waydroid.gpg] https://repo.waydro.id/ $DISTRO main" > ~/waydroid.list && \
#mv ~/waydroid.list /etc/apt/sources.list.d/waydroid.list && \
#update-alternatives --set python /usr/bin/python3.9
#apt install waydroid #failed, the armbian os depends on python3.8, while the waydoird depends python3.9 and python3-gbinder
# to compile waydroid, cost about 10 minutes on pine64
#$ sudo rm -rf /var/lib/waydroid ~/.local/share/waydroid /usr/share/waydroid-extra
#$ curl -s https://gist.githubusercontent.com/diyism/add38aaf34c4e14a76c25666439a318e/raw | bash
#now can upgrade armbian and install waydroid:
$ sudo apt update; sudo apt upgrade
$ sudo apt install curl ca-certificates -y
$ curl https://repo.waydro.id | sudo bash
$ sudo apt install waydroid -y
$ sudo waydroid init -f #or if need gapps: sudo waydroid init -s GAPPS -f
$ waydroid session start
$ sudo waydroid container start
$ waydroid status
Session: RUNNING
Container: RUNNING
Vendor type: MAINLINE
Session user: malcolm(1000)
Wayland display: wayland-0
$ waydroid show-full-ui
(011151) [14:41:37] Failed to get service waydroidplatform, trying again...
(011151) [14:41:38] Failed to get service waydroidplatform, trying again...
# A minute later, I can see the android desktop.
#upgrade the newest waydroid lineageos android image(for example 772MB: https://sourceforge.net/projects/waydroid/files/images/system/lineage/waydroid_arm64/lineage-18.1-20221111-VANILLA-waydroid_arm64-system.zip/download):
$ sudo waydroid upgrade
$ nano /etc/xdg/autostart/Waydroid.desktop
[Desktop Entry]
Type=Application
Name=Waydroid
Exec=waydroid show-full-ui #for chinese tv: "Exec=waydroid app launch com.cibn.tv", modify decoder "软解"
# Install open gapps:
#$ sudo apt install lzip
#$ git clone --depth=1 https://github.com/casualsnek/waydroid_script
#$ cd waydroid_script
#$ sudo python3 -m pip install -r requirements.txt
#$ sudo waydroid container stop
#$ sudo python3 waydroid_extras.py -i
# you can see the gsf id, or in shelter work profile use "device id(onemlab.deviceid)" app to show gsf id
# register your gsf id into google server: https://google.com/android/uncertified/?pli=1 wait for 20 mins and clear play store service cache(settings/storage/other apps) if you haved installed play store
#$ sudo python3 waydroid_extras.py -g
#need no the waydroid_script "python3 main.py certified", directly get the android_id from armbian shell:
$ echo 'ANDROID_RUNTIME_ROOT=/apex/com.android.runtime sqlite3 /data/data/com.google.android.gsf/databases/gservices.db "select * from main where name = \"android_id\";"' | sudo waydroid shell
#then fill the android_id into https://google.com/android/uncertified/?pli=1
#for workspace android_id:
$ echo 'ANDROID_RUNTIME_ROOT=/apex/com.android.runtime sqlite3 /data/user/12/com.google.android.gsf/databases/gservices.db "select * from main where name = \"android_id\";"' | sudo waydroid shell
#Waydroid.desktop里的Exec=waydroid show-full-ui能自动启动waydroid container和session, 但似乎full ui会死掉, 需要先ssh -X root@<armbian ip>, 然后:
$ su - user1
$ source source_waydroid_session.sh #export DISPLAY=":0", export WAYLAND_DISPLAY="wayland-0", export XDG_RUNTIME_DIR="/run/user/1000", ...
$ waydroid session stop
$ waydroid show-full-ui
# the color of lineage is not corrent, change it in Settings/Accessibility/Color and motion/Color inversion
#========modify keyboard, no effect========
# get the android ip:
$ waydroid shell
# adb connect
$ adb connect 192.168.240.112
# enable "rooted debugging" in settings/developer first
$ adb root
# make app window size-changable:
waydroid prop set persist.waydroid.multi_windows true
# or:
waydroid prop set persist.waydroid.width 1280
waydroid prop set persist.waydroid.height_padding 20
#========modify keyboard, has effect========
$ df #found /dev/loopX is /var/lib/waydroid/rootfs
$ losetup /dev/loopX #found /var/lib/waydroid/images/system.img
$ waydroid container stop
# should expand about 5%, for example 10MB, or esle while edit Generic.kl it complains "No space left on device"
$ dd if=/dev/zero bs=1MiB of=/var/lib/waydroid/images/system.img conv=notrunc oflag=append count=10
$ e2fsck -f /var/lib/waydroid/images/system.img #check the filesystem
$ mount -o rw /var/lib/waydroid/images/system.img /var/lib/waydroid/rootfs
$ losetup -c /dev/loop0 #resize device
$ resize2fs /dev/loop0 #resize filesystem
$ nano /var/lib/waydroid/rootfs/system/usr/keylayout/Generic.kl
# replace first line "key 1 ESCAPE" into "key 1 BACK"
$ reboot
#========================adb remote connect waydroid==============
#in armbian, must start nodeamon adb server, or else only listen on 127.0.0.1:5556:
$ adb kill-server
$ nohup adb -a nodaemon server start >/dev/null 2>&1 &
$ adb connect 192.168.240.112
$ adb forward tcp:5556 tcp:5555
#in remote linux:
$ adb connect <armbian ip>:5556
$ adb -s <armbian ip>:5556 shell screenrecord --verbose /sdcard/1.mp4
Main display is 1920x1053 @60.00fps (orientation=0)
Configuring recorder for 1920x1052 video/avc at 20.00Mbps
Content area is 1918x1052 at offset x=1 y=0
Stopping encoder and muxer
Encoder failed (err=-38)
=====================modify armbian network==============
$ sudo apt remove --purge network-manager
$ sudo systemctl enable networking
$ cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.0.169
broadcast 192.168.0.255
netmask 255.255.255.0
gateway 192.168.0.101
$ ifdown eth0
$ sudo ip addr flush dev eth0 #or else it will complain: "RTNETLINK answers: File exists"
$ sudo systemctl start networking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment