问题描述
我编译了自己的 AOSP 图像并得到了这个:
lz@vm:/mnt/android-dev-3/aosp/grapheneos-lz_experiments/out/target/product/generic_x86_64$ ls *.img
cache.img ramdisk.img system.img vendor_boot-debug.img
dtb.img ramdisk-qemu.img system-qemu.img vendor_boot.img
encryptionkey.img super_empty.img userdata.img vendor.img
ramdisk-debug.img super.img vbMeta.img vendor-qemu.img
然后我compiled my own Android emulator。
我知道我不需要自己指定 .img,AOSP 预构建模拟器就可以工作,但我想用于其他目的。
所以我做了DIR_OUT = /mnt/android-dev-3/aosp/grapheneos-lz_experiments/out/target/product/generic_x86_64
./emulator -sysdir $DIR_OUT/system -datadir $DIR_OUT/data -kernel $DIR_OUT/kernel-ranchu -ramdisk $DIR_OUT/ramdisk.img -system $DIR_OUT/system.img -data $DIR_OUT/userdata.img -cache $DIR_OUT/cache.img -vendor $DIR_OUT/vendor.img
emulator: ERROR: No AVD specified. Use '@foo' or '-avd foo' to launch a virtual device named 'foo'
emulator: WARNING: userdata partition is resized from 550 M to 800 M
emulator: WARNING: encryption is off
Segmentation fault (core dumped)
您可以通过注释 return
if (!avdName && !avdArch && !androidOut && !forceEngineLaunch && !queryVersion) {
derror("No AVD specified. Use '@foo' or '-avd foo' to launch a virtual"
" device named 'foo'\n");
//return 1;
}
因为没有它我什么都做不了。由于我的怪癖,它可能是段错误,但没有它我不知道如何使用 .img 自己运行。
以下是 android 模拟器关于指定我自己的 .img 文件的说明:
./emulator -help-disk-images
The emulator needs several key image files to run appropriately.
Their exact location depends on whether you're using the emulator
from the Android SDK,or not (more details below).
The minimal required image files are the following:
kernel-qemu the emulator-specific Linux kernel image
ramdisk.img the ramdisk image used to boot the system
system.img the *initial* system image
vendor.img the *initial* vendor image
userdata.img the *initial* data partition image
It will also use the following writable image files:
userdata-qemu.img the persistent data partition image
system-qemu.img an *optional* persistent system image
vendor-qemu.img an *optional* persistent vendor image
cache.img an *optional* cache partition image
sdcard.img an *optional* SD Card partition image
snapshots.img an *optional* state snapshots image
If you use a virtual device,its content directory should store
all writable images,and read-only ones will be found from the
corresponding platform/add-on directories. See -help-sdk-images
for more details.
If you are building from the Android build system,you should
have ANDROID_PRODUCT_OUT defined in your environment,and the
emulator shall be able to pick-up the right image files automatically.
See -help-build-images for more details.
If you're neither using the SDK or the Android build system,you
can still run the emulator by explicitely providing the paths to
*all* required disk images through a combination of the following
options: -sysdir,-datadir,-kernel,-ramdisk,-system,-data,-cache
-sdcard and -snapstorage.
The actual logic being that the emulator should be able to find all
images from the options you give it.
没有什么可以克服这个错误
更新:
sysImagePath = std::string(
avdInfo_getSystemImagePath(m_avd)
?: avdInfo_getSystemInitimagePath(m_avd));
更新:
我试过
./emulator -sysdir $DIR_OUT/system -datadir $DIR_OUT/data -kernel /home/project/disk/aosp/grapheneos-lz_experiments/prebuilts/qemu-kernel/x86_64/5.4/kernel-qemu2 -ramdisk $DIR_OUT/ramdisk-qemu.img -system $DIR_OUT/system.img -data $DIR_OUT/userdata-qemu.img -cache $DIR_OUT/cache.img -vendor $DIR_OUT/vendor.img
(我将 -qemu 添加到一些名称中包含 qemu 的 .img 中)
问题依旧存在
解决方法
试试这个。 https://source.android.com/setup/create/avd 要构建和运行 AVD 系统映像:
下载安卓源:
mkdir aosp-master; cd aosp-master 回购初始化 -u 回购同步 -j24 如果您想构建其他 Android 版本,您可以在公共 Android 存储库中找到它们的分支名称。它们映射到 Android 代号、标签和内部版本号。
构建 AVD 系统映像。这与构建 Android 设备系统映像的过程相同。例如,要构建一个 x86 32 位 AVD:
mkdir aosp-master; cd aosp-master 源 ./build/envsetup.sh 午餐 sdk_phone_x86 制作 -j32 如果您更喜欢构建 x86 64 位 AVD,请为 64 位目标运行午餐:
午餐 sdk_phone_x86_64 在 Android Emulator 中运行 AVD 系统映像:
模拟器 有关运行模拟器的更多详细信息,请参阅命令行启动选项。图 2 显示了运行 AVD 的 Android 模拟器示例。