Skip to content

Instantly share code, notes, and snippets.

@xBZZZZ
Last active May 12, 2023 12:59
Show Gist options
  • Select an option

  • Save xBZZZZ/a046bf21de2209d2cbf6779a241d6ca8 to your computer and use it in GitHub Desktop.

Select an option

Save xBZZZZ/a046bf21de2209d2cbf6779a241d6ca8 to your computer and use it in GitHub Desktop.
how to install libhoudini to Android Studio `Android 7.1.1 (Nougat)` `Intel x86 Atom_64 System Image`

use https://github.com/xBZZZZ/android_7.1.1_x86_64_libhoudini_magisk because it works with enforcing selinux

how to install libhoudini to Android Studio Android 7.1.1 (Nougat) Intel x86 Atom_64 System Image

Note: you will need to replace paths in commands in this tuturial.

ramdisk.img, system.img are located inside ~/Android/Sdk/system-images/android-25/default/x86_64 (25 is API level of Android 7.1.1, you can see it in SDK Manager).

You will need fakeroot, fuse2fs, cpio, gzip, find, fusermount3, unzip. If you are using Ubuntu you can install these using apt:

pkexec apt install fakeroot fuse2fs cpio gzip findutils fuse3 unzip

step 1: get fake root shell

fakeroot

step 2: patch system.img

Note: system.img is an ext4 file system image.

step 2.1: download houdini

Download houdini_7.1.1a_y.49564.zip from https://github.com/Rprop/libhoudini/releases/tag/v7.1.1a_y.49564/.

I downloaded houdini_7.1.1a_y.49564.zip to /tmp/houdini_7.1.1a_y.49564.zip.

step 2.2: mount system.img

I mounted system.img to /tmp/system.img_mount.

mkdir /tmp/system.img_mount
fuse2fs -o fakeroot \
  ~/Android/Sdk/system-images/android-25/default/x86_64/system.img \
  /tmp/system.img_mount

Note: -o fakeroot is needed to bypass permissions of directories and files inside system.img.

step 2.3: extract houdini_7.1.1a_y.49564.zip to system.img mountpoint

unzip /tmp/houdini_7.1.1a_y.49564.zip -x README.txt -d /tmp/system.img_mount

Note: -x README.txt is needed to not extract README.txt file.

step 2.4: make executables executable

chmod +x \
  /tmp/system.img_mount/bin/enable_nativebridge \
  /tmp/system.img_mount/bin/houdini \
  /tmp/system.img_mount/lib/arm/houdini

step 2.5: edit {system.img mountpoint}/build.prop

I used nano but you can use any other text editor.

nano /tmp/system.img_mount/build.prop

Do these edits:

  • find linereplace with
    ro.product.cpu.abilist=x86_64,x86
    ro.product.cpu.abilist=x86_64,x86,armeabi-v7a,armeabi
    ro.product.cpu.abilist32=x86
    ro.product.cpu.abilist32=x86,armeabi-v7a,armeabi
  • add to end of file:
    ro.dalvik.vm.isa.arm=x86
    ro.enable.native.bridge.exec=1

Save and exit.

step 2.6: unmount system.img

cd /
fusermount3 -u /tmp/system.img_mount

Note: cd / to avoid current working directory inside /tmp/system.img_mount.

Note: ignore the ERROR: ld.so: object 'libfakeroot-sysv.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. error.

step 3: patch ramdisk.img

Note: ramdisk.img is a gzipped cpio (New ASCII Format) archive.

step 3.1: extract ramdisk.img

I extracted ramdisk.img to /tmp/ramdisk.img_extracted.

mkdir /tmp/ramdisk.img_extracted
gzip -cd ~/Android/Sdk/system-images/android-25/default/x86_64/ramdisk.img |
  cpio --no-absolute-filenames -iH newc -D /tmp/ramdisk.img_extracted

step 3.2: edit {ramdisk.img extract dir}/default.prop

I used nano but you can use any other text editor.

nano /tmp/ramdisk.img_extracted/default.prop

Do these edits:

  • find linereplace with
    ro.dalvik.vm.native.bridge=0
    ro.dalvik.vm.native.bridge=libhoudini.so

Save and exit.

step 3.3: rearchive ramdisk.img

cd /tmp/ramdisk.img_extracted
find -print0 | cpio -o0H newc |
  gzip -c9 > ~/Android/Sdk/system-images/android-25/default/x86_64/ramdisk.img

step 4 (optional): cleanup

cd /
rmdir /tmp/system.img_mount
rm -r /tmp/ramdisk.img_extracted

Note: cd / to avoid current working directory inside /tmp/system.img_mount or /tmp/ramdisk.img_extracted.

step 5: exit fake root shell

exit

Note: need to start emulator with -selinux permissive or -selinux disabled for armeabi and armeabi-v7a apps to not crash at startup.

Note: -selinux disabled is same as -selinux permissive if you see SELinux 'disabled' is no longer supported starting with API level 23, switching to 'permissive' in terminal when starting emulator.

Note: it's possible to use houdini without -selinux permissive by setting extended attribute (attr -Ss selinux -V 'u:object_r:system_file:s0' $FILE_HERE) on all houdini files but extended attributes don't work in fuse2fs.


Thanks https://zhsj.me/blog/view/anbox-and-houdini for saying which files need to edit.

Also see https://projectproto.blogspot.com/2019/12/tvplus-go-on-laptop.html!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment