# 配置设置

本文可帮助您优化程序性能和质量，并利用 Air SDK 功能简化开发过程的基本设置。我们建议您按照本指南中的说明应用这些设置。

#### **设置目标平台**

1. 在菜单栏上，转到 File>Build Settings。
2. 在平台下，选择 Android。
3. 单击切换平台。

注意：选择 Development Build 以测试和调试应用程序。当您准备好进行 Release 构建时，请清除选择，因为它可能会影响应用程序的性能。

#### **通用设置**

1. 在菜单上，转到 Edit>Project Settings>Player，然后展开 Other Settings 选项卡。
2. 在 Other Settings 选项卡上的 Identification 下，选中 Override Default Package Name，并填写包名

![](https://testopen.rayneo.cn/media/f0449d9e34f3021aa0352d5145d0b254.png)

#### **其他配置**

1\.  在菜单上，转到 Edit>Project Settings>Player，然后展开 Publish Settings 选项卡。

2\.  在 Publish Settings 选项卡上的 Build 下，勾选 Custom Main Manifest、Custom Main Gradle Template、Custom Gradle Properties Template 三项，即可在 Unity>Project>Plugin>Android 文件夹下，找到自动生成的 AndroidManifest.xml、baseProjectTemplate.gradle、mainTemplate.gradle 文件。

![](https://testopen.rayneo.cn/media/b7ab53f789927dd2b3399cb00626b291.png)

3\.  修改 AndroidManifest.xml 文件\
Tips: SDK 定义的 UnityXRSupportActivity 作为启动 Activity,需要将启动 Activity 设置为 com.tcl.unity.unityadapter.UnityXRSupportActivity（见绿色高亮部分）

> \<?xml version="1.0" encoding="utf-8"?>\
> \<!-- GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN-->\
> \<manifest\
> &#x20;  xmlns:android="<http://schemas.android.com/apk/res/android"\\>
> &#x20;  package="com.unity3d.player"\
> &#x20;  xmlns:tools="[http://schemas.android.com/tools">\\](http://schemas.android.com/tools">\\)
> &#x20;  \<application\
> &#x20;              <mark style="background-color:$success;">android:allowBackup="true"</mark>\
> &#x20;              <mark style="background-color:$success;">android:supportsRtl="true"</mark>\
> &#x20;              <mark style="background-color:$success;">android:theme="@style/Theme.UnityAdapter"></mark>\
> &#x20;              <mark style="background-color:$success;">\<activity</mark>\
> &#x20;                  <mark style="background-color:$success;">android:name="com.tcl.unity.unityadapter.UnityXRSupportActivity"</mark>\
> &#x20;                  <mark style="background-color:$success;">android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density"</mark>\
> &#x20;                  <mark style="background-color:$success;">android:exported="true"</mark>\
> &#x20;                  <mark style="background-color:$success;">android:hardwareAccelerated="false"</mark>\
> &#x20;                  <mark style="background-color:$success;">android:launchMode="singleTask"</mark>\
> &#x20;                  <mark style="background-color:$success;">android:resizeableActivity="false"</mark>\
> &#x20;                  <mark style="background-color:$success;">android:screenOrientation="portrait"</mark>\
> &#x20;                  <mark style="background-color:$success;">android:theme="@style/Theme.UnityAdapter.NoActionBar"></mark>\
> &#x20;                      <mark style="background-color:$success;">\<intent-filter></mark>\
> &#x20;                              <mark style="background-color:$success;">\<action android:name="android.intent.action.MAIN" /></mark>\
> &#x20;                              <mark style="background-color:$success;">\<category android:name="android.intent.category.LAUNCHER" /></mark>\
> &#x20;                      <mark style="background-color:$success;">\</intent-filter></mark>\
> &#x20;                      <mark style="background-color:$success;">\<meta-data</mark>\
> &#x20;                          <mark style="background-color:$success;">android:name="unityplayer.UnityActivity"</mark>\
> &#x20;                          <mark style="background-color:$success;">android:value="true" /></mark>\
> &#x20;                      <mark style="background-color:$success;">\<meta-data</mark>\
> &#x20;                          <mark style="background-color:$success;">android:name="android.notch\_support"</mark>\
> &#x20;                          <mark style="background-color:$success;">android:value="true" /></mark>\
> &#x20;                      <mark style="background-color:$success;">\<intent-filter></mark>\
> &#x20;              <mark style="background-color:$success;">\<action android:name="com.tcl.xr.aries.action.LAUNCHER\_MAIN" /></mark>\
> &#x20;              <mark style="background-color:$success;">\<category android:name="android.intent.category.DEFAULT" /></mark>\
> &#x20;          <mark style="background-color:$success;">\</intent-filter></mark>\
> &#x20;              \</activity>\
> &#x20;  \</application>\
> \</manifest><br>

* 注 1:如果项目的编译 sdk 版本>=31,需要在 Acitivity 中加入如下配置

> \<intent-filter>\
> \
> &#x20;          \<action android:name="com.tcl.xr.aries.action.LAUNCHER\_MAIN" />\
> \
> &#x20;          \<category android:name="android.intent.category.DEFAULT" />\
> \
> \</intent-filter>

* 注 2:如果需要支持微信支付.需要在 application 标签中,加入如下属性:

> android:usesCleartextTraffic="true"

4\.  修改 gradleTemplate.properties 文件

添加对 Androidx 的支持（见绿色高亮部分）

> org.gradle.jvmargs=-Xmx\*\*JVM\_HEAP\_SIZE\*\*M\
> \
> org.gradle.parallel=true\
> \ <mark style="background-color:$success;">android.useAndroidX=true</mark>\
> \ <mark style="background-color:$success;">android.enableJetifier=true</mark>\
> \
> android.enableR8=\*\*MINIFY\_WITH\_R\_EIGHT\*\*\
> \
> unityStreamingAssets=.unity3d\*\*STREAMING\_ASSETS\*\*\
> \
> \*\*ADDITIONAL\_PROPERTIES\*\*

5\.  修改 mainTemplate.gradle 文件

添加绿色高亮部分

> // GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN\
> \
> apply plugin: 'com.android.library'\
> \*\*APPLY\_PLUGINS\*\*\
> \
> dependencies {\
> &#x20;  implementation fileTree(dir: 'libs', include: \['\*.jar'])\
> &#x20; <mark style="background-color:$success;">implementation 'com.google.android.material:material:1.5.0-alpha02'</mark>\
> &#x20;  <mark style="background-color:$success;">api 'androidx.multidex:multidex:2.0.1'</mark>\
> &#x20;  <mark style="background-color:$success;">implementation 'androidx.appcompat:appcompat:1.3.1'</mark>\
> &#x20;  <mark style="background-color:$success;">implementation 'androidx.constraintlayout:constraintlayout:1.1.3'</mark>\
> &#x20;  <mark style="background-color:$success;">implementation 'com.google.android.gms:play-services-vision:20.1.3'</mark>\
> &#x20;  <mark style="background-color:$success;">implementation 'com.google.android.material:material:1.4.0'</mark>\
> &#x20;  <mark style="background-color:$success;">implementation 'com.google.protobuf:protobuf-javalite:3.19.4'</mark>\
> \*\*DEPS\*\*}\
> \
> android {\
> &#x20;  compileSdkVersion \*\*APIVERSION\*\*\
> &#x20;  buildToolsVersion '\*\*BUILDTOOLS\*\*'\
> \
> &#x20;  compileOptions {\
> &#x20;      sourceCompatibility JavaVersion.VERSION\_1\_8\
> &#x20;      targetCompatibility JavaVersion.VERSION\_1\_8\
> &#x20;  }\
> \
> &#x20;  defaultConfig {\
> &#x20;      minSdkVersion \*\*MINSDKVERSION\*\*\
> &#x20;      targetSdkVersion \*\*TARGETSDKVERSION\*\*\
> &#x20;      ndk {\
> &#x20;          abiFilters \*\*ABIFILTERS\*\*\
> &#x20;      }\
> &#x20;      versionCode \*\*VERSIONCODE\*\*\
> &#x20;      versionName '\*\*VERSIONNAME\*\*'\
> &#x20;      consumerProguardFiles 'proguard-unity.txt'\*\*USER\_PROGUARD\*\*\
> &#x20;  }\
> \
> &#x20;  lintOptions {\
> &#x20;      abortOnError false\
> &#x20;  }\
> \
> &#x20;  aaptOptions {\
> &#x20;      noCompress = \['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')\
> &#x20;      ignoreAssetsPattern = "!.svn:!.git:!.ds\_store:!\*.scc:.\*:!CVS:!thumbs.db:!picasa.ini:!\*\~"\
> &#x20;  }\*\*PACKAGING\_OPTIONS\*\*\
> }\*\*REPOSITORIES\*\*\
> \*\*IL\_CPP\_BUILD\_SETUP\*\*\
> \*\*SOURCE\_BUILD\_SETUP\*\*\
> \*\*EXTERNAL\_SOURCES\*\*


---

# 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/air-xi-lie/unity-kai-fa/kuai-su-kai-shi/pei-zhi-she-zhi.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.
