# 快速开始

## 1. **New Project**

推荐使用Android Studio编辑器新建一个AR眼镜应用，本文使用如下版本（用户可自行选择对应的版本，建议不低于该版本）：

```yaml
Android Studio Otter 2 Feature Drop | 2025.2.2
Build #AI-252.27397.103.2522.14514259, built on December 1, 2025
Runtime version: 21.0.8+-14196175-b1038.72 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.lwawt.macosx.LWCToolkit
macOS 26.2
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 2048M
Cores: 8
Metal Rendering is ON
Registry:
  ide.experimental.ui=true
```

创建一个新的应用，选择No Activity，点击Next按钮

![](/files/db69f8b1eafd67046516eed292b7617956d315cc)

配置项输入项目名称，设置应用包名（应用标识），语言选择Kotlin

![](/files/6d594c5fea12bf8548673f7f65b742069d623ca6)

点击Finish按钮，完成项目的新建，等待项目构建成功。

## **2. 打开ViewBinding**

RayNeo ARSDK for Android基于ViewBinding进行封装，所以请先在app下的build.gradle中打开viewbinding配置

![](/files/3d2dd469d30b3504c3630c6116483cfe2d74b5a9)

```groovy
buildFeatures {
    viewBinding = true
}
```

## **3. 新建Application并配置meta-data**

在您的app的包名下新建Application类继承自Application（必须），并在AndroidManifest中关联application节点，name填写上述新建的Application类，最后添加如下标签：

![](/files/97889bee4f87a56e52d5559b2e780e831f1edb91)

```xml
<application
    android:name=".MyApplication"
   ....
   >

    <meta-data android:name="com.rayneo.mercury.app" android:value="true" />
</application>
```

在主模块AndroidManifest文件的application标签内，添加如上meta-data标签，当其value为true时，可被系统识别到，以便从默认启动入口启动您的应用。如果不添加上述标签，在眼镜的launcher里面将不显示您的应用图标。

## **4. 引入依赖**

### **AAR文件接入**

使用AAR文件依赖接入，先将aar文件复制到主模块的libs(没有该文件夹的话，请按照图示的位置进行新建)目录下，如下图所示

![](/files/dac9a74791b2fe87757d5c447f8f04df13f3b046)

在app文件夹下的build.gradle中引入如下依赖项：

![](/files/9eeb6562c012a94e9c8617128e662940fa64f967)

```groovy
// 引入aar文件
implementation(fileTree("libs"))

//补齐lifecycle-viewmodel-ktx 依赖。
implementation(libs.androidx.lifecycle.viewmodel.ktx)
```

如果遇到编译报错，请确认Gradle与AGP版本是否对应，可参考 [Android Studio 版本兼容性速查表](/rayneo-devdoc/chang-jian-wen-ti/faq/android-studio-ban-ben-jian-rong-xing-su-cha-biao.md)

## **5. 初始化SDK**

在步骤3创建的的Appliction类中调用MercurySDK.init()方法，进行初始化

![](/files/38bdbd966b69ae63ade40a22822ca4bbd4f7e401)

eg:MyApplication，初始化代码如下：

```kotlin
import com.ffalcon.mercury.android.sdk.MercurySDK
import android.app.Application

class MyApplication: Application() {
    override fun onCreate() {
        super.onCreate()
        MercurySDK.init(this)
    }
}
```

至此您已经完成RayNeo ARSDK for Android的接入。

现在您可以在app模块中新建一个MainActivity并继承SDK中的**BaseMirrorActivity**，sdk依赖了viewBinding，**BaseMirrorActivity**需要布局文件对应viewBinding类，需要在layout文件夹下创建一个xml布局文件，这里以一个包含TextView的布局为例：

![](/files/28a67701a0f3cdec3d685bb58b37c0114e5d4608)

```xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello Rayneo Glass"
        android:textColor="@color/white"
        android:textSize="36dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
```

注意不要忘记在您的AndroidManifest.xml文件中对新建的Activity进行注册：

eg:

![](/files/f3c8c0417f00afe1e0f8b081492df0ec7f0078d5)

点击运行按钮，直接运行到眼镜上，您将会看到您的第一个Rayneo Glass应用：

![](/files/722d9aa9dd1f2cfb9d4fd543acc2eb07952f8cf5)


---

# 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://rayneo.gitbook.io/rayneo-devdoc/x-xi-lie/android-kai-fa/kuai-su-kai-shi.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.
