回退 android studio emulator 的版本

前情提要

最近用 frida 需要一个完全跑 arm64 的手机 os,因为雷电实时转义 arm 到 x64 的方案本质上还是 x64,会导致 frida 有 bug。查了一下有帖子说 android studio 自带的模拟器支持直接跑 arm64 的镜像 (Other Images)

直接跑跑不通,调试一波三折。首先是报错

PANIC: Avd's CPU Architecture 'arm64' is not supported by the QEMU2 emulator on x86_64 host.

直接谷歌搜索有结果,不能用 api_version>= 28 的镜像,尝试用 27 的镜像,又报错

PANIC: QEMU2 emulator does not support arm64 CPU architecture

发现在 2024 年 8 月的 35.3 版 emulator 移除了对 non-native architecture 的支持。源码在 main-emulator.cpp,patch 是 diff

c 复制代码
 static const struct {
         const char* arch;
         const char* qemuArch;
-        const char* qemuArchForce64;
     } kQemuArchs[] = {
-            {"arm64", "aarch64", "aarch64"},
-            {"x86", "x86_64", "x86_64"},
-            {"x86_64", "x86_64", "x86_64"},
+#ifdef __aarch64__
+            {"arm64", "aarch64"},
+#endif
+#ifdef __x86_64__
+            {"x86", "x86_64"},
+            {"x86_64", "x86_64"},
+#endif
     };
     size_t n;
     for (n = 0; n < ARRAY_SIZE(kQemuArchs); ++n) {
         if (!strcmp(avdArch, kQemuArchs[n].arch)) {
-            if (force64bitTarget) {
-                return kQemuArchs[n].qemuArchForce64;
-            } else {
-                return kQemuArchs[n].qemuArch;
-            }
+            return kQemuArchs[n].qemuArch;
         }
     }
     return NULL;

该 patch 导致该函数返回 NULL,触发报错。

原本是在 x64 机器上也能匹配到 arm64 的,现在只能在 native 原生 arm 的机器上才能匹配。

回退 emulator 的版本

在官网搜到了回退版本的教程 link,并附带了 zip 压缩包。

其实就是把原来的 emulator 文件夹删了(备份),把新的解压,再把原来文件夹里面的 xml 复制过来,改一下最下面的模拟器版本就好。

添加 -qemu -machine virt 参数

换版本之后大体没问题了,但直接跑会报错 PCI bus not available for hda

Sdk\emulator\qemu\windows-x86_64\qemu-system-aarch64.exe: PCI bus not available for hda

google 了一下,添加 -qemu -machine virt 参数能用了。启动耗时 69s。

参考版本 emulator 34.2, image API27(arm)

md 但是只能装 arm64 的镜像,armeabi v7a 的镜像启不起来。有没有大手子刷到帖子的能救一下

相关推荐
荷碧TongZJ24 分钟前
Jupyter Notebook 6/7 设置代码补全
ide·python·jupyter
violin-wang1 小时前
Intellij IDEA调整栈内存空间大小详细教程,添加参数-Xss....
java·ide·intellij-idea·xss·栈内存·栈空间
接着奏乐接着舞。1 小时前
【vscode源码】如何编译运行vscode及过程中问题解决
ide·vscode·编辑器
m0_748248941 小时前
在线影视播放网站PHP电影网站源码自动采集MKCMS升级版米酷模板含WAP手机版附三套模板
android·开发语言·php
iCheer-xu2 小时前
VSCODE内使用Jupyter模式,运行backtrader不展示图片、图片尺寸无法自定义的处理方案
ide·vscode·jupyter
天边一坨浮云3 小时前
Visual Studio踩过的坑
ide·visual studio
Mekeater3 小时前
手写一个C++ Android Binder服务及源码分析
android·c++·binder·remote·iservicemanager·bpbinder·bprefbase
Mr.L-OAM5 小时前
SQL自学,mysql从入门到精通 --- 第 15天,数据导入、导出
android·sql·mysql
you来有去6 小时前
idea启动报错# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffccf76e433
java·ide·intellij-idea
xvch7 小时前
Kotlin 2.1.0 入门教程(十一)for、while、return、break、continue
android·kotlin