android AVD 安装houdini

ref:

https://blog.csdn.net/tkwxty/article/details/107608252

https://dev.to/csjoy/add-arm-support-to-anbox-5668

 

Houdini: run Arm 32-bit and 64-bit applications on an x86_64 system

 

Guide:
1. Download the Android command line tools (installing the whole Android studio is only optional).
https://developer.android.com/studio, e.g. extract sdk-tools-linux-4333796.zip to ~/android/sdk.

2. Open a terminal, change directory to ~/android/sdk, and set the following environment variables:

$ export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
$ export ANDROID_HOME=$HOME/android/sdk
$ export ANDROID_SDK_ROOT=$ANDROID_HOME

3. Download the emulator, platform-tools, and the system-image. Android Nougat (API-25) is selected because easier to modify compared to with the recent versions.

$ ./tools/bin/sdkmanager "platform-tools" "platforms;android-25" "emulator"
$ ./tools/bin/sdkmanager --install "system-images;android-25;google_apis;x86_64"

4. Go to $ANDROID_SDK_ROOT/system-images/android-25/google_apis/x86_64 and increase the size of the system.img (create a backup first!). Allocate at least 128MB for the additional files.

$ cd $ANDROID_SDK_ROOT/system-images/android-25/google_apis/x86_64
$ dd if=/dev/zero bs=1M count=512 >> ./system.img
$ e2fsck -f system.img
$ resize2fs system.img

5. Copy libhoudini binaries. Mount first the system.img before extracting the files.

$ wget http://dl.android-x86.org/houdini/7_y/houdini.sfs -O houdini_7_y.sfs
$ mkdir -p systemfs
$ sudo mount -o loop -t ext4 system.img systemfs
$ sudo unsquashfs -d systemfs/lib/arm houdini_7_y.sfs
$ sudo cp systemfs/lib/arm/libhoudini.so systemfs/lib/
$ sudo cp systemfs/lib/arm/houdini systemfs/bin/

Either set the selinux to permissive (add -selinux permissive option on the emulator) or set the security context of the libhoudini files.

$ sudo setfattr -n security.selinux -v u:object_r:system_file:s0 systemfs/bin/houdini
$ sudo setfattr -n security.selinux -v u:object_r:system_file:s0 systemfs/lib/libhoudini.so
$ sudo setfattr -n security.selinux -v u:object_r:system_file:s0 systemfs/lib/arm
$ sudo setfattr -n security.selinux -v u:object_r:system_file:s0 systemfs/lib/arm/*
$ sudo setfattr -n security.selinux -v u:object_r:system_file:s0 systemfs/lib/arm/nb/*

6. Allows ARM executable file formats

$ sudo mkdir -p systemfs/etc/binfmt_misc
$ echo ":arm_dyn:M::x7fx45x4cx46x01x01x01x00x00x00x00x00x00x00x00x00x03x00x28::/system/bin/houdini:" | sudo tee systemfs/etc/binfmt_misc/arm_dyn
$ echo ":arm_exe:M::x7fx45x4cx46x01x01x01x00x00x00x00x00x00x00x00x00x02x00x28::/system/bin/houdini:" | sudo tee systemfs/etc/binfmt_misc/arm_exe

$ sudo nano systemfs/build.prop

add the following properties to the build.prop (overwrite if existing):

ro.enable.native.bridge.exec=1

ro.product.cpu.abilist=x86_64,x86,armeabi-v7a,armeabi
ro.product.cpu.abilist32=x86,armeabi-v7a,armeabi

 

7. Enable access to the TVPlus Go USB dongle (vendor id 0x048d, product id 0x9308)

$ echo '<permissions><feature name="android.hardware.usb.host"/></permissions>' | sudo tee systemfs/etc/permissions/android.hardware.usb.host.xml
$ echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="048d", ATTRS{idProduct}=="9308", GROUP="kvm"' | sudo tee /etc/udev/rules.d/89-usb-android.rules
$ sudo udevadm control --reload-rules

8. Hide from “root-detection” and “running-on-emulator-detection”
i. rename the su executable

$ sudo mv systemfs/xbin/su systemfs/xbin/_s_u

ii. edit again build.prop, check these answers on which properties to be modified. Replace, at least, the “generic” string from ro.product.device and ro.build.fingerprint(not the actual workaround)

iii. (optional) Install Google Play, if you want to watch the encrypted channels – need to pay P20 for the registration (in-app purchase). Copy “Phonesky.apk” from opengapps.org to systemfs/priv-app/Phonesky

iv. finally, unmount the image.

$ sync
$ sudo umount systemfs

9. Extract ramdisk, and edit default.prop

$ mkdir -p ramdiskfs
$ cd ramdiskfs
$ gzip -dc ../ramdisk.img | cpio -i

$ nano default.prop

Replace ro.dalvik.vm.native.bridge=0 with ro.dalvik.vm.native.bridge=libhoudini.so

10. Edit an init configuration file (e.g. init.ranchu.rc) to register the libhoudini by adding these lines:

# Enable native bridge for target executables
on early-init
    mount binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc

on property:ro.enable.native.bridge.exec=1
    copy /system/etc/binfmt_misc/arm_exe /proc/sys/fs/binfmt_misc/register
    copy /system/etc/binfmt_misc/arm_dyn /proc/sys/fs/binfmt_misc/register

11. Repack the new ramdisk

$ cd ..
$ wget https://github.com/xiaolu/mkbootimg_tools/raw/master/mkbootfs
$ chmod +x mkbootfs
$ ./mkbootfs ./ramdiskfs | gzip > ramdisk.img

12. Create the AVD named “avd_7_1_x86_64” based on “Android TV (720p)” device.

$ ./tools/bin/avdmanager --verbose create avd --force --name "avd_7_1_x86_64" --device "tv_720p" 
  --package "system-images;android-25;google_apis;x86_64" --tag "google_apis" --abi "x86_64"

13. Now launch the emulator.

$ ./tools/emulator @avd_7_1_x86_64 -show-kernel -verbose -memory 2048 
  -qemu -usb -device usb-host,vendorid=0x048d,productid=0x9308

14. Install the TVplus Go Android app, either via the Google Play or via adb install

$ adb install ../apks/TVplus GO_v1.0.28_apkpure.com.apk

15. Finally, plugin the TVplus Go dongle to a USB port and then launch now the app on the emulator

虚拟机安装android-x86

1.下载

https://osdn.net/projects/android-x86/releases

选择k49版本(kernel 4.9)

2.安装

默认安装,/system选择read/write

3.虚拟机设置

3.1 virtualbox

1.CPU 勾选虚拟化支持

2.显示选项:选择VboxSVGA,去除3D加速

3.2 vmware

vi /mnt/grub/menu.lst

replace quiet to nomodeset xforcevesa DPI=320

最后加上

vga=ask(ask可以替换为后来的分辨率代码)

 

 

 

4.安装houdini库

4.1 Android x86 Arm NativeBridge (libhoudini)

Houdini is an ARM translation layer for android developed by Intel and Google to run ARM apps on x86 architecture. The project is closed source and nowadays android x86 doesn’t have it pre-installed in the system. To enable ARM Native Bridge on android x86 you need to run the enable_nativebridge command from the terminal, which downloads the .sfs image file from the android x86 servers and runs the ARM activation commands according to your device architecture.

There are mainly 3 types of libhoudini used in android x86 :-

  • houdini_7_x = (x86 arm translation)
  • houdini_7_y = (x86_64 arm translation)
  • houdini_7_z = (x86_64 arm64 translation)

Houdini files are named according to their android version :-

  • Houdini_6 series = android 6.0
  • Houdini_7 series = android 7.0
  • Houdini_8 series = android 8.0
  • Houdini_9 series = android 9.0

Houdini_6 series can be used in android 7.1 as well and the Houdini_8 series can be used in Android 9.0, but a higher version of Houdini is not compatible with the lower version of android.

Download Links :-

Houdini_6 series

 

http://dl.android-x86.org/houdini/6_x/houdini.sfs
http://dl.android-x86.org/houdini/6_y/houdini.sfs
http://dl.android-x86.org/houdini/6_z/houdini.sfs

Houdini_7 series

 

http://dl.android-x86.org/houdini/7_x/houdini.sfs
http://dl.android-x86.org/houdini/7_y/houdini.sfs
http://dl.android-x86.org/houdini/7_z/houdini.sfs

Houdini_8 series

http://dl.android-x86.org/houdini/8_x/houdini.sfs
http://dl.android-x86.org/houdini/8_y/houdini.sfs

Houdini_9 series

http://dl.android-x86.org/houdini/9_y/houdini.sfs

How to manually install Arm Native Bridge in android x86

  • Download the required .sfs file from the above links.
  • Rename the file houdini.sfs to houdini7_y.sfs
  • Copy the houdini7_y.sfs file to /data/arm/ folder
  • Do the same for the z series if you want to run the arm64 app.
  • Press alt+f1 to open terminal & run the command enable_nativebridge.
  • if you don’t get any error msg then you’ve successfully activated ARM Native Bridge on your system.
  • Press alt+f7 to return to GUI & download any game/app to test libhoudini.

4.2 connetc adb

adb connect *.*.*.*:5555
adb push houdini.sfs /sdcard/

4.3 启用houdini库

:/sdcard # cp houdini.sfs /system/etc/houdini{version}_y.sfs
:/sdcard # cp houdini.sfs /system/etc/houdini{version}_z.sfs
:/sdcard # /system/bin/enable_nativebridge
:/sdcard # reboot

注:

1.{version}为对应android版本

2.android 8、9无houdini z.sfs

 

5.系统设置

进入系统,在设置->应用兼容性->兼容模式

启用兼容模式

 

6.相关快捷键

右ctr+h 电源

win   Home

menu  menu

alt+tab 任务切换

 

 

android-x86 设置

1.兼容性问题

Android x86 默认不带houdini,运行纯ARM版会提示:

很抱歉,”xxxx”已停止运行

设置->应用兼容性->打开

终端模拟器

$ su
# enable_nativebridge

 

脚本会自动下载houdini.tgz并解压到相应位置

 

2.网络设置

网络设置为桥架模式

adb connect 192.168.56.101:5555
adb devices
adb -s 192.168.56.101:5555 root
adb -s 192.168.56.101:5555 shell

 

3.ADB安装app

adb install ***.apk