# Build Your First App in Java

### **Create a new project** <a href="#step-1-create-a-new-project" id="step-1-create-a-new-project"></a>

Open Android Studio.

In the Welcome to Android Studio dialog, click Start a new Android Studio project.&#x20;

![](https://developer.android.com/codelabs/build-your-first-android-app/img/c7c8a5cc4c9029b.png)

&#x20;Select **Basic Activity** (not the default). Click **Next**.

![](https://developer.android.com/codelabs/build-your-first-android-app/img/73e63b490a2f4ae6.png)

Give your application a name.

Make sure the Language is set to Java(Development in Kotlin is supported but this guide will cover java development).&#x20;

Make sure to set Minimum SDK Version” to “27”

![](https://developer.android.com/codelabs/build-your-first-android-app/img/3ffb3ca42472b4f6.png)

**Click Finish**.

### Modify the Layout of your application

Main Activity is the run screen that a user will encounter when open your app. Navigate to activity\_main.xml on the left pane.&#x20;

<div align="left"><img src="/files/-MUjbPPVRHWXHhjqkdn9" alt=""></div>

This should open the layout manger.&#x20;

Switch to visual layout mode.

<div align="left"><img src="/files/-MVNRFrYRI9AFtNVuqCY" alt=""></div>

Change the device to TV(720p) and the orientation to landscape.

![](/files/-MUjdLNMOgbzaFr8xviq)

Ensure that all other layouts are configured the same way.

Your application is now be ready to run on the X2 headset.

### Run your app on X2 <a href="#step-6-run-your-app-on-a-device-if-you-have-one" id="step-6-run-your-app-on-a-device-if-you-have-one"></a>

What you need:

* A USB-C Cable to connect X2 to USB port on your computer.
* If you are using a Linux or Windows OS, you may need to perform additional steps to run your app on X2 Check the [Run Apps on a Hardware Device](http://developer.android.com/tools/device.html) documentation. On Windows, you may need to install the appropriate USB driver for your device.

#### **Run your app on a device**

To let Android Studio communicate with your device, you must turn on USB Debugging on your Android device. By Default X2 has ADB(Android Debug Bridge) enabled.

If for some reason it is disable you can enable it by"

1. On your device, open **Settings > About phone** and tap **Build number** seven times.
2. Return to the previous screen (**Settings**). **Developer options** appears at the bottom of the list. Tap **Developer options**.
3. Enable **USB Debugging**.

#### Starting your app

1. Connect your device to your development machine with a USB cable. On the device, you might need to agree to allow USB debugging from your development device.
2. In Android Studio, click **Run** ![609c3e4473493202.png](https://developer.android.com/codelabs/build-your-first-android-app/img/609c3e4473493202.png) in the toolbar at the top of the window.  The **Select Deployment Target** dialog opens with the list of available emulators and connected devices.
3. Select your device, and click **OK**. Android Studio installs the app on your device and runs it.


---

# 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://thirdeyegen.gitbook.io/developer-portal/android-development/build-your-first-app-in-java.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.
