在 Android 模拟器中运行 AR 应用
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
使用 Android 模拟器在没有实体设备的情况下测试 AR 场景。借助 Android 模拟器,您可以在虚拟环境中运行 ARCore 应用,并使用您控制的模拟设备。
设置您的开发环境
软件要求:
安装 Android Studio 3.1 或更高版本。
在 Android Studio 中,前往 Preferences > Appearance and Behavior > System Settings > Android SDK。
选择 SDK Platforms 标签页,然后选中 Show Package Details。
在相应的 Android 版本下,选择:
Google APIs Intel x86 Atom System Image API 级别 27 或更高版本。
选择 SDK Tools 标签页,然后添加 Android Emulator 27.2.9 或更高版本。
点击 OK 以安装所选软件包和工具。
再次点击 OK 以确认更改。
Accept 组件安装程序的许可协议。
点击 Finish。
创建支持 AR 的虚拟设备
如需了解详情,请参阅 Android Studio 中有关创建虚拟设备的说明。
创建新的 Android 虚拟设备 (AVD)
在 Android Studio 中,点击 Tools > Device Manager 打开设备管理器。
点击设备管理器面板顶部的 Create Device。
选择或创建所需的手机硬件配置文件,然后选择 Next。
选择运行 API 级别 27 或更高级别的 x86
或 x86_64
系统映像,然后选择 Next。
验证虚拟设备是否已正确配置:
点击 Finish 以创建 AVD。
运行应用
在模拟器中支持 AR 的虚拟设备上测试 ARCore 应用。为此,您可以按照 Android Studio 说明在 Android 模拟器中运行应用。
更新“面向 AR 的 Google Play 服务”
模拟器上的“面向 AR 的 Google Play 服务”版本可能已过时。请按照以下说明更新该应用:
从 GitHub 版本页面下载最新的 Google_Play_Services_for_AR_1.50.0_x86_for_emulator.apk。
将下载的 APK 安装到您要使用的每个 AVD 中:
启动所需的 AVD,然后将下载的 APK 从系统文件夹(即 Downloads)到正在运行的模拟器上,或者在虚拟设备运行时使用 adb
安装它:
adb install -r Google_Play_Services_for_AR_1.50.0_x86_for_emulator.apk
对于您想要使用的任何其他 AVD,请重复上述步骤。
控制虚拟场景
当应用连接到 ARCore 时,您会看到一个叠加层,其中介绍了如何控制摄像头,以及模拟器窗口下方的状态栏。
![]()
移动虚拟摄像头
按住 Shift 可访问相机移动控制功能。
使用以下控件移动摄像头:
操作 |
您需要采取的措施 |
向左或向右移动 |
按住 Shift 并按 A 或 D |
向下或向上移动 |
按住 Shift 的同时,按 Q 或 E |
向前移动或向后移动 |
按住 Shift 并按 W 或 S |
更改设备方向 |
按住 Shift 键并移动鼠标 |
释放 Shift 以返回到模拟器中的交互模式。
使用扩展控件中的 Virtual Sensors 标签页可更精确地定位设备。
向场景添加增强图像
将图片加载到模拟器的模拟环境中,以测试增强现实图片。
![]()
使用 Extended controls 中的 Camera 标签页可添加或修改 Scene images。
有两个图片位置,一个在墙上,一个在桌子上。
![]()
如需在场景中查看这些图片位置,请启动模拟器,然后通过摄像头起始位置后面的门将摄像头移动到餐厅区域。
问题排查提示
如果您的 ARCore 应用启动后,您看到“此设备不支持 AR”消息,请检查系统映像的修订版本。请确保您使用的是 API 级别 27 修订版 4 或更高版本。
如果您的 ARCore 应用在启动时无法打开相机,请确保 Camera Back 设置为 VirtualScene,如上述配置步骤中所述。
如果您的 ARCore 应用无法打开,并显示“Failed to create AR session”错误消息,请检查应用日志。如果您发现 java.lang.UnsatisfiedLinkError
包含 /lib/arm/libarcore_c.so" is for EM_ARM (40)
instead of EM_386 (3)
的消息,则可能安装了错误的 Google Play Services for AR APK 版本。创建新的虚拟设备并安装 x86 版本。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eUse the Android Emulator to test AR scenarios without a physical device by running ARCore apps in a virtual environment.\u003c/p\u003e\n"],["\u003cp\u003eSet up your development environment by installing Android Studio 3.1 or later and Android Emulator 27.2.9 or later, then create a virtual device with AR support by configuring it with an x86 or x86_64 system image running API Level 27 or later and setting the Camera Back to VirtualScene.\u003c/p\u003e\n"],["\u003cp\u003eUpdate Google Play Services for AR on the emulator by downloading and installing the latest APK from the GitHub releases page.\u003c/p\u003e\n"],["\u003cp\u003eControl the virtual scene by pressing and holding Shift for camera movements and using the Virtual Sensors tab in Extended controls for precise positioning, while adding Augmented Images using the Camera tab in Extended controls to load images into the simulated environment.\u003c/p\u003e\n"]]],["To test AR apps without a physical device, use the Android Emulator. First, install Android Studio and the required SDK tools (Android Emulator 27.2.9+ and Google APIs Intel x86 Atom System Image API Level 27+). Create a new Android Virtual Device (AVD) with an x86 system image, ensuring \"Camera Back\" is set to \"VirtualScene.\" Update Google Play Services for AR by installing the correct APK. Control the virtual camera using Shift and WASDQE keys. Add scene images via Extended Controls.\n"],null,["# Run AR Apps in Android Emulator\n\nUse the [Android Emulator](https://developer.android.com/studio/run/emulator.html)\nto test AR scenarios without a physical device. The Android Emulator lets you\nrun ARCore apps in a virtual environment with an emulated device that you\ncontrol.\n\nSet up your development environment\n-----------------------------------\n\nSoftware requirements:\n\n- [Android Studio](https://developer.android.com/studio/) **3.1** or later.\n\n- [Android Emulator](https://developer.android.com/studio/run/emulator.html#Requirements)\n **27.2.9** or later.\n\nGet Android Studio and SDK tools for ARCore\n-------------------------------------------\n\n1. Install [Android Studio](https://developer.android.com/studio/) 3.1 or later.\n\n2. In Android Studio, go to **Preferences \\\u003e Appearance and Behavior \\\u003e System Settings \\\u003e Android SDK**.\n\n3. Select the **SDK Platforms** tab and check **Show Package Details**.\n\n Under the appropriate Android version select: \n\n **Google APIs Intel x86 Atom System Image** API Level 27 or later.\n4. Select the **SDK Tools** tab and add **Android Emulator** 27.2.9 or later.\n\n5. Click **OK** to install the selected packages and tools.\n\n6. Click **OK** again to confirm changes.\n\n7. **Accept** the license agreement for the Component Installer.\n\n8. Click **Finish**.\n\nCreate a virtual device with AR support\n---------------------------------------\n\nFor more information, see the Android Studio instructions to [Create a\nVirtual Device](https://developer.android.com/studio/run/managing-avds.html#createavd).\n\n### Create a new Android Virtual Device (AVD)\n\n1. In Android Studio open the *Device Manager* by clicking **Tools \\\u003e Device Manager**.\n\n2. Click **Create Device** , at the top of the *Device Manager* panel.\n\n3. Select or create your desired *Phone* hardware profile and select **Next**.\n\n4. Select an `x86` or `x86_64` system image running **API Level 27 or later**\n and select **Next** . \n\n - While physical ARCore devices are supported on API Level 24 or later,\n Android Emulator support requires API Level 27 or later.\n\n - Only x86-based Android Emulator architectures are supported. Other\n architectures such as `arm64-v8a`, `armeabi-v7`, are not currently\n supported.\n\n5. Verify that your virtual device is configured correctly:\n\n - Click **Show Advanced Settings**.\n\n - Make sure that **Camera Back** is set to **VirtualScene**.\n\n6. Click **Finish** to create your AVD.\n\nRun your app\n------------\n\nTest an ARCore app on an AR-supported virtual device in the emulator. To do\nthis, you can follow the Android Studio instructions to\n[Run an app in the Android Emulator](https://developer.android.com/studio/run/emulator.html#runningapp).\n| **Note:** To run apps with NDK components in the Android Emulator, your app must be built with [**x86 ABIs**](https://developer.android.com/ndk/guides/abis.html). For an example, see the [**ARCore HelloAR C sample app**](https://github.com/google-ar/arcore-android-sdk/tree/master/samples/hello_ar_c).\n\n### Update Google Play Services for AR\n\nThe version of Google Play Services for AR on the emulator is likely out of\ndate. Follow these instructions to update it:\n\n1. Download the latest **Google_Play_Services_for_AR_1.50.0_x86_for_emulator.apk** from the GitHub\n [releases](https://github.com/google-ar/arcore-android-sdk/releases) page.\n\n2. Install the downloaded APK into each AVD you'd like to use:\n\n Start the desired AVD, then drag the downloaded APK from your system folder\n (i.e., **Downloads** ) onto the running\n emulator, or install it using `adb` while the virtual device is running: \n\n ```\n adb install -r Google_Play_Services_for_AR_1.50.0_x86_for_emulator.apk\n ```\n\n \u003cbr /\u003e\n\nRepeat these steps process for any additional AVDs you'd like to use.\n\n### Control the virtual scene\n\nWhen your app connects to ARCore, you'll see an overlay describing how to control\nthe camera and a status bar below the emulator window.\n\n#### Move the virtual camera\n\nPress and hold **Shift** to access camera movement controls.\nUse the following controls to move the camera:\n\n\u003cbr /\u003e\n\n| Action | What to do |\n|---------------------------|---------------------------------------|\n| Move left or right | Hold **Shift** + press **A** or **D** |\n| Move down or up | Hold **Shift** + press **Q** or **E** |\n| Move forward or back | Hold **Shift** + press **W** or **S** |\n| Change device orientation | Hold **Shift** + move mouse |\n\n\u003cbr /\u003e\n\nRelease **Shift** to return to interactive mode in the emulator.\n\nUse the **Virtual Sensors** tab in [Extended controls](https://developer.android.com/studio/run/emulator.html#extended)\nfor more precise device positioning.\n\n### Add Augmented Images to the scene\n\nLoad images into the emulator's simulated environment to test [Augmented Images](/ar/develop/augmented-images).\n\nUse the **Camera** tab in **Extended controls** to add or modify **Scene images**.\nThere are two image locations, one on the wall and one on the table.\n\nTo view these image locations in the scene, launch your emulator, then move the\ncamera to the dining room area through the door behind the camera's starting\nposition.\n\n### Troubleshooting tips\n\n- If your ARCore app launches and you see a \"This device does not support AR\"\n message, check the revision on your system image. Make sure you are using\n **API Level 27 Revision 4 or later**.\n\n- If your ARCore app fails to open the camera when it launches, make sure that\n **Camera Back** is set to **VirtualScene** ,\n as described in the [configuration steps above](#configure_the_virtual_device).\n\n- If your ARCore app fails to open with the error message \"Failed to create AR\n session\" check the app log. If you find a `java.lang.UnsatisfiedLinkError`\n with a message that contains `/lib/arm/libarcore_c.so\" is for EM_ARM (40)\n instead of EM_386 (3)`, you may have installed the wrong version of the\n **Google Play Services for AR** apk. Create a new virtual device and install\n the x86 version."]]