这篇文章上次修改于 539 天前,可能其部分内容已经发生变化,如有疑问可询问作者。
前言
说起来还么有试过x86版本的redroid
环境
- Ubuntu 20.04.4 LTS x86_64
- VMware开启虚拟化支持
执行grep -c -w "vmx\|svm" /proc/cpuinfo
命令,如果结果大于0说明虚拟化已经开启
步骤
安装docker
这一步不必多说,请参考官方指南
安装内核模块
sudo apt install linux-modules-extra-`uname -r`
sudo modprobe binder_linux devices="binder,hwbinder,vndbinder"
sudo modprobe ashmem_linux
sudo modprobe binfmt_misc
修改内核参数
如果你使用的是Ubuntu 22.04
则需要做这一步,参考官方说明
即编辑/etc/default/grub
,给GRUB_CMDLINE_LINUX
添加上systemd.unified_cgroup_hierarchy=0
设置selinux
sudo apt install selinux-utils
setenforce 0
启动redroid
我这里选的是redroid/redroid:12.0.0-amd64
docker run -itd --rm --privileged \
--pull always \
-v ~/data:/data \
-p 5555:5555 \
redroid/redroid:12.0.0-amd64
adb devices
看下,是正常的
前面已经把5555转发到虚拟机了,并且监听在0.0.0.0
,那么现在可以在宿主机连接到redroid
体验
尝试安装一个小红书,失败了,这是因为这里面只有arm64-v8a
架构的so
>adb install com.xingin.xhs_7.65.0.apk
Performing Streamed Install
adb: failed to install com.xingin.xhs_7.65.0.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113]
补充native-bridge
sudo apt install curl rsync zip unzip binwalk p7zip-full
根据说明,先clone这个项目
git clone https://gitlab.com/android-generic/android_vendor_google_emu-x86 vendor/google/emu-x86 --depth=1
然后执行这个命令,就会在当前目录下得到一个native-bridge.tar
. vendor/google/emu-x86/update.sh x86_64
新建一个文件夹,把这个文件复制进去,然后新建一个Dockerfile
文件,内容如下
FROM redroid/redroid:11.0.0-amd64
ADD native-bridge.tar /
执行下面的命令进行打包
docker build . -t redroid:11.0.0-amd64-nb
然后启动重新打包的容器
docker run -itd --rm --privileged \
-v ~/data11-nb:/data \
-p 5555:5555 \
redroid:11.0.0-amd64-nb \
ro.product.cpu.abilist=x86_64,arm64-v8a,x86,armeabi-v7a,armeabi \
ro.product.cpu.abilist64=x86_64,arm64-v8a \
ro.product.cpu.abilist32=x86,armeabi-v7a,armeabi \
ro.dalvik.vm.isa.arm=x86 \
ro.dalvik.vm.isa.arm64=x86_64 \
ro.enable.native.bridge.exec=1 \
ro.dalvik.vm.native.bridge=libndk_translation.so \
ro.ndk_translation.version=0.2.2 \
androidboot.redroid_gpu_mode=host
可以看到启动成功,scrcpy正常投屏
abi信息也有arm结构了
小红书安装上了,但是加载打开失败
--------- beginning of crash
02-10 02:02:26.416 5942 5942 E AndroidRuntime: FATAL EXCEPTION: main
02-10 02:02:26.416 5942 5942 E AndroidRuntime: Process: com.xingin.xhs, PID: 5942
02-10 02:02:26.416 5942 5942 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: "/data/data/com.xingin.xhs/app_lib/libsecurebase.so" is for EM_AARCH64 (183) instead of EM_X86_64 (62)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at java.lang.Runtime.load0(Runtime.java:939)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at java.lang.System.load(System.java:1628)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at b6.d.c(Unknown Source:0)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at b6.c.g(ReLinkerInstance.java:24)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at b6.c.f(ReLinkerInstance.java:3)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at b6.b.b(Unknown Source:5)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at b6.b.a(Unknown Source:1)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at com.xingin.security.base.acdd.onCreate(Unknown Source:12)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at android.content.ContentProvider.attachInfo(ContentProvider.java:2388)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at android.content.ContentProvider.attachInfo(ContentProvider.java:2358)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:7246)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at android.app.ActivityThread.installContentProviders(ActivityThread.java:6787)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6704)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at android.app.ActivityThread.access$1300(ActivityThread.java:237)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at android.os.Looper.loop(Looper.java:223)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7664)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
02-10 02:02:26.416 5942 5942 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
02-10 02:02:26.419 215 518 W ActivityTaskManager: Force finishing activity com.xingin.xhs/.index.v2.IndexActivityV2
看来性能不够呀,重新加内存试试
02-10 02:38:05.800 2102 2102 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
02-10 02:38:05.800 2102 2102 F DEBUG : Build fingerprint: 'redroid/redroid_x86_64/redroid_x86_64:11/RD2A.211001.002/eng.frank.20221027.124148:userdebug/test-keys'
02-10 02:38:05.800 2102 2102 F DEBUG : Revision: '0'
02-10 02:38:05.800 2102 2102 F DEBUG : ABI: 'x86_64'
02-10 02:38:05.801 2102 2102 F DEBUG : Timestamp: 2023-02-10 02:38:05+0000
02-10 02:38:05.801 2102 2102 F DEBUG : pid: 1605, tid: 2091, name: RxCachedThreadS >>> com.xingin.xhs <<<
02-10 02:38:05.801 2102 2102 F DEBUG : uid: 10116
02-10 02:38:05.801 2102 2102 F DEBUG : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x7d8d936d167c
02-10 02:38:05.801 2102 2102 F DEBUG : rax 0000000000000000 rbx 0000000000000000 rcx 0000000000000000 rdx 0000000000000000
02-10 02:38:05.801 2102 2102 F DEBUG : r8 0000000000000000 r9 0000000000000000 r10 0000000000000000 r11 0000000000000000
02-10 02:38:05.801 2102 2102 F DEBUG : r12 0000000000000000 r13 0000000000000000 r14 0000000000000000 r15 0000000000000000
02-10 02:38:05.801 2102 2102 F DEBUG : rdi 0000000000000000 rsi 0000000000000000
02-10 02:38:05.801 2102 2102 F DEBUG : rbp 0000000000000000 rsp 0000000000000000 rip 0000000000000000
02-10 02:38:05.801 2102 2102 F DEBUG : backtrace:
02-10 02:38:05.801 2102 2102 F DEBUG : #00 pc 0000000000000000 <unknown>
02-10 02:38:06.037 1967 1967 I MMKV : <native-bridge.cpp:95::JNI_OnLoad> current API level = 30
02-10 02:38:06.044 1967 1967 I MMKV : <MMKV.cpp:192::initialize> page size:4096
02-10 02:38:06.059 1967 1967 I MMKV : <MMKV.cpp:206::initializeMMKV> root dir: /data/user/0/com.xingin.xhs/files/mmkv
02-10 02:38:06.060 1967 1967 I MMKV_Recycler: recycler enabled = false
32位的抖音也不行...
--------- beginning of crash
02-10 02:41:18.085 3171 3273 F libc : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 3273 (tp-io-9), pid 3171 (droid.ugc.aweme)
02-10 02:41:18.262 3384 3384 I crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
02-10 02:41:18.262 48 48 I tombstoned: received crash request for pid 3273
02-10 02:41:18.262 3384 3384 I crash_dump32: performing dump of process 3171 (target tid = 3273)
02-10 02:41:18.290 3384 3384 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
02-10 02:41:18.290 3384 3384 F DEBUG : Build fingerprint: 'redroid/redroid_x86_64/redroid_x86_64:11/RD2A.211001.002/eng.frank.20221027.124148:userdebug/test-keys'
02-10 02:41:18.291 3384 3384 F DEBUG : Revision: '0'
02-10 02:41:18.291 3384 3384 F DEBUG : ABI: 'x86'
02-10 02:41:18.291 3384 3384 F DEBUG : Timestamp: 2023-02-10 02:41:18+0000
02-10 02:41:18.291 3384 3384 F DEBUG : pid: 3171, tid: 3273, name: tp-io-9 >>> com.ss.android.ugc.aweme <<<
02-10 02:41:18.291 3384 3384 F DEBUG : uid: 10117
02-10 02:41:18.291 3384 3384 F DEBUG : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
02-10 02:41:18.291 3384 3384 F DEBUG : Abort message: 'vendor/unbundled_google/libs/ndk_translation/runtime/host_call_frame_arm.cc:65: CHECK failed: 2875488936 == 2875490272'
02-10 02:41:18.291 3384 3384 F DEBUG : eax 00000000 ebx 00000c63 ecx 00000cc9 edx 00000006
02-10 02:41:18.291 3384 3384 F DEBUG : edi f1c8b81e esi ac18bae0
02-10 02:41:18.291 3384 3384 F DEBUG : ebp f5986540 esp ac18ba88 eip f5986549
02-10 02:41:18.448 3384 3384 F DEBUG : backtrace:
02-10 02:41:18.449 3384 3384 F DEBUG : #00 pc 00000549 [vdso] (__kernel_vsyscall+9)
02-10 02:41:18.449 3384 3384 F DEBUG : #01 pc 0005b3e8 /apex/com.android.runtime/lib/bionic/libc.so (syscall+40) (BuildId: a9827ed2eeb48572d9f00a06c690d153)
02-10 02:41:18.449 3384 3384 F DEBUG : #02 pc 00076ae1 /apex/com.android.runtime/lib/bionic/libc.so (abort+209) (BuildId: a9827ed2eeb48572d9f00a06c690d153)
02-10 02:41:18.449 3384 3384 F DEBUG : #03 pc 0067b392 /apex/com.android.art/lib/libart.so (art::Runtime::Abort(char const*)+2674) (BuildId: 6c7ef9fd857ff6cc49114cbdaba4e8c8)
02-10 02:41:18.449 3384 3384 F DEBUG : #04 pc 00025ff3 /apex/com.android.art/lib/libartbase.so (std::__1::__function::__func<void (*)(char const*), std::__1::allocator<void (*)(char const*)>, void (char const*)>::operator()(char const*&&)+35) (BuildId: fbb345606231bba002006d8b518f6d45)
02-10 02:41:18.449 3384 3384 F DEBUG : #05 pc 0001596f /system/lib/libbase.so (android::base::SetAborter(std::__1::function<void (char const*)>&&)::$_3::__invoke(char const*)+79) (BuildId: df8f279adb58d3909b00d1b4bfdd1490)
02-10 02:41:18.449 3384 3384 F DEBUG : #06 pc 00006d8d /system/lib/liblog.so (__android_log_assert+253) (BuildId: 36545d3ec578aad4b74c396bfd26296e)
02-10 02:41:18.449 3384 3384 F DEBUG : #07 pc 000d0cd7 /system/lib/libndk_translation.so (ndk_translation::ScopedHostCallFrame::~ScopedHostCallFrame()+231) (BuildId: c8028e297933f35487f96cff20830f87)
02-10 02:41:18.449 3384 3384 F DEBUG : #08 pc 000d04b9 /system/lib/libndk_translation.so (ndk_translation::(anonymous namespace)::RunGuestCall(unsigned int, int, int, unsigned int*)+313) (BuildId: c8028e297933f35487f96cff20830f87)
02-10 02:41:18.449 3384 3384 F DEBUG : #09 pc 000d036b /system/lib/libndk_translation.so (ndk_translation::GuestCall::RunVoid(unsigned int)+43) (BuildId: c8028e297933f35487f96cff20830f87)
0
至少启动界面是能看到的,就是电脑性能捉急...不折腾了,还是rock5b香
没有评论