从源代码构建 Android - 模拟器和 AVD

发布于 2024-11-27 10:33:54 字数 1436 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

输什么也不输骨气 2024-12-04 10:33:54

您分享了:

显然,诸如 ANDROID_PRODUCT_OUT 之类的变量应该在构建期间并使用 envSetup.sh 脚本自动创建。我猜我的环境设置出了问题,所以不会发生这种情况。

我也尝试让它工作并了解到:

  1. lunch full-eng 设置所有适当的环境
  2. 来检查它,只需运行:
    环境| grep ANDROID
    您将看到所有适当的环境变量设置。
    这些仅适用于当前 shell!
  3. 然后模拟器就会做它应该做的事情。

当我稍后回到 shell 时,我只是再次运行午餐 full-eng 来恢复我的环境。
我希望这也对其他人有帮助!

You shared that:

Apparently variables such as ANDROID_PRODUCT_OUT should be automatically created during a build and using the envSetup.sh script. I guess something has gone wrong with my environment setup for this not to happen.

I ALSO ATTEMPTED to get this to work and LEARNED that:

  1. lunch full-eng sets up all the appropriate env
  2. to check it, simply run:
    env | grep ANDROID
    and you will see all the appropriate env variables setup.
    These are local to the current shell only!
  3. emulator then does what it should.

When I came back to the shell later, I simply ran lunch full-eng again to restore my environment.
I hope this helps others as well!

梦途 2024-12-04 10:33:54

只需执行以下操作:

source build/envsetup.sh or . build/envsetup.sh
setpaths

就可以了。确保从源目录运行它。

Just do the following:

source build/envsetup.sh or . build/envsetup.sh
setpaths

That does the trick. Make sure you run it from your source directory.

迷路的信 2024-12-04 10:33:54

为了检查我为模拟器构建的源,我在项目的根文件夹中创建了以下脚本。我从另一个命令行运行它,它不需要一直运行。 build/envsetup.shlunch full-eng 命令。您可以根据需要编辑此脚本,如果您需要运行其他设备 - 只需更改文件夹即可。

out/host/linux-x86/bin/emulator -sysdir out/target/product/generic/ -system out/target/product/generic/system.img -ramdisk out/target/product/generic/ramdisk.img -data out/target/product/generic/userdata.img -kernel prebuilt/android-arm/kernel/kernel-qemu -sdcard sdcard.img -skindir sdk/emulator/skins -skin WVGA800 -scale 0.7 -memory 512 -partition-size 1024

To check my built sources for emulator I've created the following script in the root folder of the project. I run it from another command line and it does not require to run all the time running . build/envsetup.sh and lunch full-eng commands. You can edit this script for your needs and if you need to run other device - simply change folder.

out/host/linux-x86/bin/emulator -sysdir out/target/product/generic/ -system out/target/product/generic/system.img -ramdisk out/target/product/generic/ramdisk.img -data out/target/product/generic/userdata.img -kernel prebuilt/android-arm/kernel/kernel-qemu -sdcard sdcard.img -skindir sdk/emulator/skins -skin WVGA800 -scale 0.7 -memory 512 -partition-size 1024
满身野味 2024-12-04 10:33:54

您可以将这些添加到您的 .bashrc 文件中

export ANDROID_PRODUCT_OUT=$ANDROID_SRC/out/target/product/generic
export ANDROID_BIN=$ANDROID_SRC/out/host/linux-x86/bin
PATH=$ANDROID_BIN:$PATH

You can add these to your .bashrc file

export ANDROID_PRODUCT_OUT=$ANDROID_SRC/out/target/product/generic
export ANDROID_BIN=$ANDROID_SRC/out/host/linux-x86/bin
PATH=$ANDROID_BIN:$PATH
遇见了你 2024-12-04 10:33:54

事实上,“emulator”程序只是真正的emulator-qemu的包装,例如emulator-arm或emulator-x86。您调用的“模拟器”将收集您输入的参数并找到要执行的正确模拟器-qemu。

您遇到的问题是您没有明确描述要启动哪个图像/avd。您可以使用参数“@avd YOUR-AVD_NAME”或“ANDROID_PRODUCT_OUT”环境变量来设置放置avd的目录。顺便说一句,avd dir 包含一些文件来描述该设备的外观。

“.build/envsetup.sh”是为Android构建过程设置环境变量的脚本。所以就很容易理解为什么当时会设置“ANDROID_PRODUCT_OUT”了。它的默认值应该是“PATH/TO/ANDROID/out/target/product/generic”。

PS:如果想了解更多,可以参考源文件:“PATH/TO/ANDROID/external/qemu/android/main-emulator.c”。您可以在那里找到模拟器主程序。

In fact, the program "emulator" is just a wrapper for the real emulator-qemu, such as emulator-arm or emulator-x86. The "emulator" you invoked will collect the arguments you typed in and find the proper emulator-qemu to execute.

The problem you met is that you did not explicitly describe which image/avd you want to start. You can either using the argument "@avd YOUR-AVD_NAME" or "ANDROID_PRODUCT_OUT" environment variable to set the dir where your avd is placed. BTW, avd dir contains some files to describe how this device looks like.

". build/envsetup.sh" is the script that set the environment variables for the Android build process. So it is easy to understand why "ANDROID_PRODUCT_OUT" will be set at that time. Its default value should be "PATH/TO/ANDROID/out/target/product/generic".

PS: If you want to know more, you can refer to the source file: "PATH/TO/ANDROID/external/qemu/android/main-emulator.c". You can find the emulator main there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文