# Getting Started with NRSDK

Start developing your NRSDK Unity apps on Android phone.

This quickstart guide will help you set up your development environment and test out the sample app “Hello MR” using NRSDK.

### 1. Pre-requisites

**Hardware Checklist**

* A supported Android Phone. Please review the[ Device Compatibility](https://xreal.gitbook.io/nrsdk/v2.1.0/nrsdk-fundamentals/xreal-devices/compatibility) list to ensure your phone model is compatible with the glasses and NRSDK.
* A pair of **XREAL** glasses.
* **Android Debug Bridge** [(adb)](https://developer.android.com/studio/command-line/adb). Wireless ADB is not required but **strongly recommended**, so that repetitive plug in/out can be avoided.

**Software Checklist**

* [Unity 2019.4.X or later](https://unity3d.com/get-unity/download) with Android Build Support\
  Unity LTS (Long Term Support) version is recommended
* Latest [NRSDK for Unity](https://developer.xreal.com/download)

  The SDK is downloaded as `NRSDKForUnity_x.x.x.unitypackage`
* Android SDK 10.0 (API Level 29) or later, installed using the SDK Manager in [Android Studio](https://developer.android.com/studio)
* [Visual Studio](https://visualstudio.microsoft.com/downloads/) (if you prefer other development environments that’s fine too)

### 2. Creating a Unity Project

We’re going to create a new Unity project and integrate NRSDK later on. To create a new Unity project:

* Open Unity Hub and create a new 3D project.
* Import NRSDK for Unity
  * Select `Assets>Import Package>Custom` Package.
  * Select the `NRSDKForUnity_x.x.x.unitypackage` that you downloaded.
  * In the **Importing** Package dialog, make sure that all package options are selected and click **Import**.

### 3. Configure Project Settings

You could either configure your project automatically via NRSDK **Project Tips** tool or configure manually. These two ways are equivalent.

#### **Project Tips tool**

* Go to NRSDK -> Project Tips in Unity menu

![](https://1774958057-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIM2VX8TwuOpFaP0UDa6i%2Fuploads%2FiYSD9cyHIJjpegQTjryc%2Fimage.png?alt=media\&token=4a3be733-5247-486d-864a-0745e753247e)

* Click **Accept All** in the popup window

![](https://1774958057-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIM2VX8TwuOpFaP0UDa6i%2Fuploads%2F2PBrjCbTV2VoLE87IaEu%2Fimage.png?alt=media\&token=d2047cf9-c2c3-4d54-9cc9-c39d50402648)

* Wait for Unity to process. The **Project Tips** window should appear as empty when finished.

![](https://1774958057-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIM2VX8TwuOpFaP0UDa6i%2Fuploads%2FuBMhWW1D1KNGMeS4325j%2Fimage.png?alt=media\&token=3190e11f-35e3-4b20-abf4-83f5b7e67ec6)

* Close the Project Tips window
* Most of the settings have been completed here, but `OpenGL ES3` and `Write Permission` still need to be manually configured. Please refer to the manual configuration path below for specific settings.

#### **Manual Configuration**

* Go to **File > Build Settings**.
* Select **Android** and click **Switch Platform**.
* In the **Build Settings** window, click **Player Settings**.
* In the **Inspector** window, configure player settings as follows:

<table data-header-hidden><thead><tr><th width="462.6819657753787"></th><th></th></tr></thead><tbody><tr><td><strong>Setting</strong></td><td><strong>Value</strong></td></tr><tr><td><code>Player Settings > Resolution and Presentation > Default Orientation</code></td><td>Portrait</td></tr><tr><td><code>Player Settings > Other Settings > Auto Graphics API</code></td><td>false</td></tr><tr><td><code>Player Settings > Other Settings > Graphics APIs</code></td><td>OpenGL ES3</td></tr><tr><td><code>Player Settings > Other Settings > Package Name</code></td><td>Create a unique app ID using a Java package name format.<br>For example, use <strong>com.xreal.helloMR</strong></td></tr><tr><td><code>Player Settings > Other Settings > Minimum API Level</code></td><td>Android 8.0 or higher</td></tr><tr><td><code>Player Settings > Other Settings > Target API Level</code></td><td>Automatic (highest installed)</td></tr><tr><td><code>Player Settings > Other Settings > Write Permission</code></td><td>External(SDCard)</td></tr><tr><td><code>Project Settings > Quality > VSync Count</code></td><td>Don't Sync</td></tr></tbody></table>

### 4. Configure Compatible Devices&#x20;

You could specify Target Devices in `Assets/NRSDK/NRProjectConfig.` Be aware that **all the NRSDK features supported by XREAL Air are supported by XREAL Light** . By default, both `Support XREAL Light`(VISION) and `Support XREAL Air`(REALITY) are selected.

![](https://1774958057-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIM2VX8TwuOpFaP0UDa6i%2Fuploads%2FfIvGtLUnnoqS2Z7CWjSz%2Fimage.png?alt=media\&token=aa88f82d-cada-4ee6-83c7-990a570384bb)

<figure><img src="https://1774958057-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIM2VX8TwuOpFaP0UDa6i%2Fuploads%2Ffzycx4N08DALShnmQTEB%2Fimage.png?alt=media&#x26;token=eb50cf65-bab9-426f-8064-c7228bd2e17c" alt=""><figcaption></figcaption></figure>

By selecting VISION, NRSDK will automatically attempt to adapt to XREAL Air, XREAL Air 2 or XREAL Air 2 Pro even if you had implemented NRSDK features that are based on RGB Camera (plane detection, image tracking, hand tracking, recording, etc. See [Device Compatibility](https://xreal.gitbook.io/nrsdk/v2.1.0/nrsdk-fundamentals/xreal-devices/compatibility) for details). However, be aware that the actual behavior of the adapted application may differ from your initial intent.

If you only want the application to run on a specific device (Light/Air), you may arbitrarily specify a single target device. In this way, NRSDK will not try to adapt automatically, and the app will not run on unsupported devices.

### 5. Configure AR Features

* Find and click `Assets/NRSDK/NRKernalSessionConfig` in Unity project folder, make sure the plane tracking, image tracking is configured properly as the following default configuration:&#x20;

<figure><img src="https://1774958057-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIM2VX8TwuOpFaP0UDa6i%2Fuploads%2FNgSt4Yw5wmIMlgh6pB4s%2Fimage.png?alt=media&#x26;token=07881bd0-58f5-43f3-b26e-7eddea7dad88" alt=""><figcaption></figcaption></figure>

* Force Kill While Glass Switch Mode: Unselect this option to ensure your app will not be killed when users switch the mode between 2D and 3D mode.
* Support Mono Mode: MonoMode is a special feature in our AR system that simulates a 3D experience on a 2D display with a resolution of 1920\*1080. When enabled, it allows 3D applications to run without errors, even if not switched to 3D mode via Nebula, by mirroring the content for the left and right eyes. For more details, please refer to [render-monomode](https://xreal.gitbook.io/nrsdk/v2.1.0/development/miscellaneous/render-monomode "mention").

Please note that **Plane Finding Mode** and **Image Tracking Mode** will implicitly be **Disable** when `Support XREAL Air` is selected in **Step 4:  Configure Compatible Devices,** regardless of your configuration here in the inspector.

### 6. Find Hello MR Sample Scene

* Find the **HelloMR** sample scene in the Unity Project window by selecting `Assets > NRSDK > Demos > HelloMR.`
* Double click `HelloMR` to open the scene

![](https://1774958057-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIM2VX8TwuOpFaP0UDa6i%2Fuploads%2F33tgFJcUOPeJx3CvvW2x%2Fimage.png?alt=media\&token=4050ee22-7ca2-4fcd-bed9-b90c5a00d324)

### 7. Building NRSDK App for Android

1. Access the **Build Settings** in **Menu -> File ->** **Build Settings**. Click the button "`Add Open Scene`" and make sure the current scene is checked.&#x20;

![](https://1774958057-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIM2VX8TwuOpFaP0UDa6i%2Fuploads%2F84wgBEYufX58gWq0doUt%2Fimage.png?alt=media\&token=670e0b19-a0e2-4064-ab9d-f20fa01ad5fd)

2\. Click **Player Settings**. Customize the **Company Name** and **Product Name.**&#x20;

3\. (Optional) Navigate to the **Android**> **Other Settings** panel to specify your build settings. As you have prepared **Step 3. Configure Project Settings,** you may leave the current configuration as it is. It is worth noting some of the other settings:

* **Multithreaded Rendering**: Enable this option to use multithreaded rendering. In most cases, both enabling and disabling this option is supported by NRSDK. However, for the scenes that contains **Overlay** content, you should disable multithreaded rendering.
* **Scripting Backend:** Choose either IL2CPP or Mono, but you can only choose IL2CPP when building for ARM64 architecture.

![](https://1774958057-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIM2VX8TwuOpFaP0UDa6i%2Fuploads%2FtQg5I9SGC6hSItvoFRtI%2Fimage.png?alt=media\&token=aff38883-27ca-4154-938c-3cc2105a04bf)

4\. In **Build Settings** window, click **Build.**

5\. Select the destination folder and wait until the building is finished.

### 8. Deploy to XREAL Device

* Connect your Phone / computing unit to your Mac / Windows PC.&#x20;
* Install your app through WiFi **Android Debug Bridge** [(adb)](https://developer.android.com/studio/command-line/adb) or type-C cable after the build is successful.
* Disconnect the computing unit with your PC, and then connect it to the glasses.
* (Computing Unit only) If it is the first time you run this app, you need to authorize the app by some tools like [scrcpy](https://github.com/Genymobile/scrcpy).
* Launch your app along with the XREAL Light controller. For instructions on how to use the XREAL Light controller, please refer to [Controller](https://nrealsdkdoc2.readthedocs.io/en/dev/Docs/Unity_EN/Develop/Controller.html#controller-guide).
* Move around until NRSDK finds a horizontal plane and the detected plane will be covered with green grid.
* Click the Trigger button to put an XREAL logo object on it.
* (Optional) Use **Android Logcat** to view logged messages. We recommend using WiFi **Android Debug Bridge** [(adb)](https://developer.android.com/studio/command-line/adb) to connect to your PC so that you do not have to be connected through the data cable most of the time.
* Enable developer options and USB debugging on your Phone / Computing unit. **Android Debug Bridge** [(adb)](https://developer.android.com/studio/command-line/adb) is enabled as default and does not require manual setting.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xreal.gitbook.io/nrsdk/v2.1.0/nrsdk-fundamentals/quickstart-for-android.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
