我正在尝试使用 Unity 3D 发布 Oculus GO 应用程序构建。我按照 OVR 说明发布此类应用程序,可在此处找到:https ://developer.oculus.com/documentation/mobilesdk/latest/concepts/mobile-native-manifest/
说明中提到您必须使用 Oculus -> Tools -> Create Store Compatible AndroidManifest.xml,然后在其中填写应用程序的详细信息。
Oculus 工具生成的 AndroidManifest.xml 文件如下:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto">
<application
android:allowBackup="false">
<activity
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
android:launchMode="singleTask"
android:name="com.unity3d.player.UnityPlayerActivity"
android:excludeFromRecents="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.INFO"/>
</intent-filter>
</activity>
<meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="false" />
</application>
</manifest>
根据上面 Oculus 网站上的说明(例如添加包名称等)编辑清单文件后,我的清单文件如下所示:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xx.xx.xx"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto">
<application>
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only"/>
<activity
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
android:configChanges="density|keyboard|keyboardHidden|navigation|orientation|screenLayout|screenSize|uiMode"
android:launchMode="singleTask"
android:name="com.unity3d.player.UnityPlayerActivity"
android:excludeFromRecents="true"
android:resizeableActivity="false"
>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.INFO"/>
</intent-filter>
</activity>
<meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="false" />
</application>
<uses-sdk android:minSdkVersion="21"/>
<uses-feature android:glEsVersion="0x00030001" />
</manifest>
当我尝试构建应用程序时,它显示以下错误:
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.XR.Oculus.OculusManifest.UpdateOrCreateNameValueElementsInTag (System.Xml.XmlDocument doc, System.String parentPath, System.String tag, System.String firstName, System.String firstValue, System.String secondName, System.String secondValue, System.String thirdName, System.String thirdValue) (at Library/PackageCache/com.unity.xr.oculus.android@1.38.2/Editor/OculusBuildProcessor.cs:60)
UnityEditor.XR.Oculus.OculusManifest.OnPostGenerateGradleAndroidProject (System.String path) (at Library/PackageCache/com.unity.xr.oculus.android@1.38.2/Editor/OculusBuildProcessor.cs:102)
UnityEditor.Android.AndroidBuildPipelineInterfaces.OnGeneratePlatformProjectPostprocess (System.String path, System.Boolean strict) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Android/AndroidPostGenerateGradleProject.cs:39)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
我必须提到,如果我构建应用程序时不使用使用 Oculus 工具创建的 AndroidManifest.xml 文件,它构建得很好。