تشغيل تطبيقات Sceneform في Android Emulator
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
استخدام محاكي Android
لاختبار سيناريوهات الواقع المعزّز بدون استخدام جهاز فعلي يتيح لك محاكي Android
تشغيل تطبيقات ARCore في بيئة افتراضية باستخدام جهاز محاكاة
تتحكم فيه.
إعداد بيئة التطوير
متطلبات البرامج:
متطلبات الأجهزة:
- ستحتاج أيضًا إلى جهاز تطوير يدعم OpenGL ES 3.0 أو إصدارًا أحدث لاستخدام Sceneform في تطبيقك.
ثبِّت استوديو Android 3.1 أو إصدار أحدث.
في "استوديو Android"، انتقِل إلى الإعدادات المفضّلة > والمظهر والسلوك > إعدادات النظام > وحزمة تطوير البرامج (SDK) لنظام التشغيل Android.
اختَر علامة التبويب SDKs Platforms (المنصات المتعلّقة بحزمة تطوير البرامج (SDK)) وضع علامة في المربّع Show Package Details (عرض تفاصيل الحزمة).
ضمن Android 8.1 (Oreo)، اختَر:
Google APIs Intel x86 Atom System Image المستوى 27، الإصدار 4 أو الإصدارات الأحدث.
اختَر علامة التبويب أدوات SDK وأضِف Android Emulator 27.2.9 أو إصدارًا أحدث.
انقر على OK (حسنًا) لتثبيت الأدوات والمعدّات المحدّدة.
انقر على حسنًا مرة أخرى لتأكيد التغييرات.
اقبل اتفاقية الترخيص لأداة تثبيت المكوّنات.
انقر على إنهاء.
إنشاء جهاز افتراضي متوافق مع ميزة الواقع المعزّز
يمكنك اتّباع تعليمات "استوديو Android" من أجل إنشاء جهاز افتراضي
مع تفعيل ميزة الواقع المعزّز.
يتطلّب Sceneform استخدام OpenGL ES 3.0 أو إصدار أحدث.
تأكّد من ضبط المحاكي لاستخدام أحدث إصدار من OpenGL ES:
- انقر على
في شريط أدوات المحاكي قيد التشغيل.
- انقر على الإعدادات >؛ الإعدادات المتقدّمة >؛ مستوى واجهة برمجة تطبيقات OpenGL ES؛gt؛
الحد الأقصى لأداة العرض (ما يصل إلى OpenGL ES 3.1).
- أعِد تشغيل المحاكي. لا تعرض الحالة الحالية عندما يُطلب منك ذلك.
بعد إعادة تشغيل المحاكي، يمكنك التفاعل لفترة قصيرة مع خطوات المحاكاة، ثم التحقّق مما إذا كان يتم استخدام OpenGL ES 3.0 أو إصدار أحدث من خلال إزالة سجلّات الجهاز:
adb logcat | grep eglMakeCurrent
إذا ظهر لك الإصدار ver 3 0
أو إصدار أحدث، يمكنك تشغيل تطبيقات Sceneform
في المحاكي:
… … … … D EGL_emulation: eglMakeCurrent: 0xebe63540: ver 3 0 (tinfo 0xd104cb40)
إذا كنت ترى إصدارًا أقل، هذا يعني أن وحدة معالجة الرسومات للكمبيوتر المكتبي لا تتوافق مع OpenGL ES 3.0 وعليك بدلاً من ذلك استخدام جهاز متوافق لتشغيل تطبيقات Sceneform.
تشغيل تطبيقك
اختبِر تطبيق ARCore على جهاز افتراضي متوافق مع الواقع المعزّز في المحاكي. لإجراء ذلك، يمكنك اتّباع تعليمات"استوديو Android" لتشغيل تطبيق في"محاكي Android".
تحديث "خدمات Google Play للواقع المعزّز"
من المحتمل أن يكون إصدار "خدمات Google Play للواقع المعزّز" على المحاكي قديمًا. اتّبِع التعليمات التالية لتعديل الخطوات التالية:
نزِّل أحدث إصدارات Google_Play_Services_for_AR_1.15.0_x86_for_emulator.jpg من صفحة إصدارات GitHub.
ثبِّت ملف APK الذي تم تنزيله في كل فيديو تريد استخدامه:
ابدأ تشغيل AVD المطلوب، ثم اسحب ملف APK الذي تم تنزيله على محاكي
التشغيل، أو ثبِّته باستخدام adb
أثناء تشغيل الجهاز الافتراضي:
adb install -r Google_Play_Services_for_AR_1.15.0_x86_for_emulator.apk
كرِّر هذه الخطوات مع أي ملفات AVD إضافية تريد استخدامها.
التحكّم في المشهد الافتراضي
عندما يتصل تطبيقك بـ ARCore، سيظهر لك تراكب يصف كيفية التحكّم في الكاميرا وشريط الحالة أسفل نافذة المحاكي.
![]()
تحريك الكاميرا الافتراضية
اضغط مع الاستمرار على Option (نظام التشغيل macOS) أو Alt (نظام التشغيل Linux أو Windows) للوصول إلى عناصر التحكم في حركة الكاميرا. استخدِم عناصر التحكّم التالية لتحريك الكاميرا:
النظام الأساسي |
الإجراء |
ما يجب فعله |
نظام التشغيل macOS
|
تحريك لليسار أو اليمين
|
الضغط مع الاستمرار على Option + الضغط على A أو D
|
|
النقل لمستوى أدنى أو أعلى
|
الضغط مع الاستمرار على Option + الضغط على Q أو E
|
|
التحرك إلى الأمام أو الخلف
|
الضغط مع الاستمرار على Option + الضغط على W أو S
|
|
تغيير اتجاه الجهاز
|
الضغط مع الاستمرار على Option + تحريك الماوس
|
نظام التشغيل Linux أو نظام التشغيل Windows
|
تحريك لليسار أو اليمين
|
الضغط مع الاستمرار على Alt + A أو D
|
|
النقل لمستوى أدنى أو أعلى
|
الضغط مع الاستمرار على Alt + Q أو E
|
|
التحرك إلى الأمام أو الخلف
|
الضغط مع الاستمرار على Alt + W أو S
|
|
تغيير اتجاه الجهاز
|
الضغط مع الاستمرار على Alt + تحريك الماوس
|
اضغط على Option أو Alt للعودة إلى الوضع التفاعلي في المحاكي.
يمكنك استخدام علامة التبويب أجهزة الاستشعار الافتراضية في عناصر التحكّم الموسَّعة
لتحديد الموقع الجغرافي للجهاز بدقة أكبر.
ملاحظات حول تحديد المشاكل وحلّها
إذا تم تشغيل تطبيق ARCore وظهرت لك رسالة "&AR Core غير متوافقة"، راجِع النسخة المراجعة على صورة النظام. احرص على استخدام واجهة برمجة التطبيقات للمستوى 27 من واجهة برمجة التطبيقات.
إذا تعذّر على تطبيق ARCore فتح الكاميرا عند تشغيلها، احرص على ضبط
الكاميرا الخلفية على القيمة VirtualScene كما هو موضّح في خطوات
الضبط أعلاه.
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2022-09-26 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2022-09-26 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eThe Android Emulator can be used to test ARCore apps in a virtual environment without a physical device, using a controlled emulated device.\u003c/p\u003e\n"],["\u003cp\u003eTo use the emulator for AR development, you need Android Studio 3.1 or later and Android Emulator 27.2.9 or later, along with a development machine supporting OpenGL ES 3.0 or higher.\u003c/p\u003e\n"],["\u003cp\u003eYou can create a virtual device with AR support by selecting the Pixel or Pixel 2 hardware profile and the Oreo: API Level 27: x86: Android 8.1 (Google APIs) system image, while ensuring the Camera Back is set to VirtualScene.\u003c/p\u003e\n"],["\u003cp\u003eTo configure the emulator to support Sceneform, you need to set the OpenGL ES API level to Renderer maximum (up to OpenGL ES 3.1) and verify that the emulator is using at least version 3.0.\u003c/p\u003e\n"],["\u003cp\u003eTo control the virtual camera within the AR environment, press and hold Option (macOS) or Alt (Linux/Windows) and use the A, S, D, W, Q, or E keys, or move the mouse for device orientation changes.\u003c/p\u003e\n"]]],["To test AR apps without a physical device, use the Android Emulator. First, install Android Studio 3.1+ and Android Emulator 27.2.9+. Configure the emulator with a Pixel/Pixel 2 device, Android 8.1 (API 27) system image, and set \"Camera Back\" to \"VirtualScene.\" Ensure OpenGL ES 3.0+ is enabled and update Google Play Services for AR. Control the virtual camera using Option/Alt plus WASD/QE keys or mouse movement. Finally, run the app on the emulator and interact with the AR environment.\n"],null,["# Run Sceneform apps in Android Emulator\n\nUse the [Android Emulator](//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](//developer.android.com/studio/) **3.1** or later.\n\n- [Android Emulator](//developer.android.com/studio/run/emulator.html#requirements)\n **27.2.9** or later.\n\nHardware requirements:\n\n- You'll also need a development machine that supports **OpenGL ES 3.0** or higher to use Sceneform in your app.\n\nGet Android Studio and SDK tools for ARCore\n-------------------------------------------\n\n1. Install [Android Studio](//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 **Android 8.1 (Oreo)** , select: \n\n **Google APIs Intel x86 Atom System Image** API Level 27, version 4 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 pacakges 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\nYou can follow the Android Studio instructions to [create a\nVirtual Device](//developer.android.com/studio/run/managing-avds.html#createavd)\nwith AR support.\n\n### Configure the virtual device\n\n- Select the **Pixel** or **Pixel 2** hardware profile.\n- Select the **Oreo: API Level 27: x86: Android 8.1 (Google APIs)** system image.\n- Confirm that your virtual device is configured correctly:\n\n - Go to **Verify Configuration \\\u003e Show Advanced Settings**.\n - Make sure that **Camera Back** is set to **VirtualScene**.\n\nConfigure the emulator to support Sceneform\n-------------------------------------------\n\nSceneform requires **OpenGL ES 3.0** or higher.\n\n1. Make sure your emulator is configured to use the latest version of\n OpenGL ES:\n\n - Click in the running emulator's toolbar.\n - Select **Settings \\\u003e Advanced \\\u003e OpenGL ES API level \\\u003e\n Renderer maximum (up to OpenGL ES 3.1)**.\n - Restart the emulator. When prompted, do not save the current state.\n2. After restarting the emulator, briefly interact with the emulated deivce,\n then check whether OpenGL ES 3.0 or higher is being used by grepping the\n device logs:\n\n \u003cbr /\u003e\n\n ```\n adb logcat | grep eglMakeCurrent\n ```\n\n \u003cbr /\u003e\n\n If you see **`ver 3 0`** or higher version, then you can run Sceneform\n apps in the emulator: \n\n ```\n … … … … D EGL_emulation: eglMakeCurrent: 0xebe63540: ver 3 0 (tinfo 0xd104cb40)\n ```\n\n \u003cbr /\u003e\n\n If you see a lower version, then your desktop GPU does not support\n OpenGL ES 3.0 and you must instead use a physical\n [supported device](/ar/discover/supported-devices) to run Sceneform apps.\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](//developer.android.com/studio/run/emulator.html#runningapp) to\nrun an app in the Android Emulator.\n| **Note:** To run apps with NDK components in the Android Emulator, your app must be built with [**x86 ABIs**](//developer.android.com/ndk/guides/abis.html). For an example, see the [**ARCore HelloAR C sample app**](//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.15.0_x86_for_emulator.apk** from the GitHub\n [releases](//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 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.15.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 **Option** (macOS) or **Alt** (Linux or Windows) to access camera\nmovement controls. Use the following controls to move the camera:\n\n\u003cbr /\u003e\n\n| Platform | Action | What to do |\n|--------------------------|---------------------------|----------------------------------------|\n| **macOS** | Move left or right | Hold **Option** + press **A** or **D** |\n| | Move down or up | Hold **Option** + press **Q** or **E** |\n| | Move forward or back | Hold **Option** + press **W** or **S** |\n| | Change device orientation | Hold **Option** + move mouse |\n| **Linux** or **Windows** | Move left or right | Hold **Alt** + press **A** or **D** |\n| | Move down or up | Hold **Alt** + press **Q** or **E** |\n| | Move forward or back | Hold **Alt** + press **W** or **S** |\n| | Change device orientation | Hold **Alt** + move mouse |\n\n\u003cbr /\u003e\n\nRelease **Option** or **Alt** to return to interactive mode in the emulator.\n\nUse the **Virtual Sensors** tab in [Extended controls](//developer.android.com/studio/run/emulator.html#extended)\nfor more precise device positioning.\n\n### Troubleshooting tips\n\n- If your ARCore app launches and you see an \"AR Core not supported\" message,\n check the revision on your system image. Make sure you are using\n **API Level 27 Revision 4**.\n\n- If your ARCore app fails to open the camera when it launches, make sure that\n **Camera Back** is set to **VirtualScene** , as described in the [configuration\n steps above](#configure_the_virtual_device)."]]