TLabAltoh / TLabWebViewVR

Sample Unity project for using TLabWebView in OculusQuest. Includes Meta XR SDK and XR Interaction Toolkit implementation example.
https://tlabgames.gitbook.io/tlabwebview/
MIT License
42 stars 9 forks source link

There is a issue about androidmanifest.xml #11

Closed TREEANA closed 7 months ago

TREEANA commented 1 year ago

Form the your TLabWebViewVR Asset migration tutorial (https://www.youtube.com/watch?v=_Tj6pHsAz6M)

I followed your guidelines, but encountered four problems while building.

I am currently working through the Quest 2 and I think there is a problem with androidmanifest XML file. The following is my problem code. 1) NullReferenceException: Object reference not set to an instance of an object AndroidManifest.SetHardwareAccelerated (System.Boolean enabled) (at Assets/TLab/TLabWebView/Editor/UnityWebViewPostprocessBuild.cs:145) UnityWebViewPostprocessBuild.OnPostGenerateGradleAndroidProject (System.String basePath) (at Assets/TLab/TLabWebView/Editor/UnityWebViewPostprocessBuild.cs:25) UnityEditor.Android.PostProcessor.Tasks.ProcessGenerateProjectCallbacks.OnGeneratePlatformProjectPostprocess (System.String path, System.Boolean strict) (at <0f901cb1488646d79bc8fbaad188a860>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

2) NullReferenceException: Object reference not set to an instance of an object AndroidManifest.SetHardwareAccelerated (System.Boolean enabled) (at Assets/TLab/TLabWebView/Editor/UnityWebViewPostprocessBuild.cs:145) UnityWebViewPostprocessBuild.OnPostGenerateGradleAndroidProject (System.String basePath) (at Assets/TLab/TLabWebView/Editor/UnityWebViewPostprocessBuild.cs:25) UnityEditor.Android.PostProcessor.Tasks.ProcessGenerateProjectCallbacks.OnGeneratePlatformProjectPostprocess (System.String path, System.Boolean strict) (at <0f901cb1488646d79bc8fbaad188a860>:0) UnityEditor.Android.PostProcessor.Tasks.ProcessGenerateProjectCallbacks.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <0f901cb1488646d79bc8fbaad188a860>:0) 3) Build completed with a result of 'Failed' in 7 seconds (6973 ms)2 errorsUnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Can you help me?

TLabAltoh commented 1 year ago

Sorry for the late reply. The video was missing the step to create a custom android manifest during the build. Go to project settings, create a custom android manifest, and add the following

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto">
  <application android:label="@string/app_name" android:icon="@mipmap/app_icon" 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.LAUNCHER" />
      </intent-filter>
    </activity>
    <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="false" />
    <meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only" />
  </application>

    <!-- For Unity-WebView Add this -->
    <application android:allowBackup="true"/>
    <application android:supportsRtl="true"/>
    <application android:hardwareAccelerated="true"/>
    <application android:usesCleartextTraffic="true"/>

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.MICROPHONE" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.microphone" />
    <!-- For Unity-WebView -->

  <uses-feature android:name="android.hardware.vr.headtracking" android:version="1" android:required="true" />
</manifest>

This should make for a successful build...

Let me know if it doesn't work out.

TREEANA commented 1 year ago

Thank you for responding.

It still not worked

I copied the XML from your GitHub exactly as it is, but I'm still encountering the same error I mentioned earlier.

I am currently using the Quest 2, and when I initially created the Unity project, I set it up with a VR template.

Could you try creating a new project again to check if it builds successfully?

image

image

TLabAltoh commented 1 year ago

ok. thanks for the report. I'll check it later in the same environment.

TREEANA commented 1 year ago

Thanks so much, I really want to run your app.

aequivalent2 commented 1 year ago

Hello and sorry to bother you again. I am encountering the same issue but on a different Unity Version, i am currently using Unity 2022.3.13f1 LTS. Is it possible to support this Version?

TLabAltoh commented 1 year ago

Sorry for the late reply, I tested the build on 2022.3.11f1 and faced the same problem.

I have created a sample for the XR Interaction Framework that works with version 2022.1* or later, so please check it out.

The custom android manifest shown in the sample 2021 version does not work with 2022, so please build without it. (Uncheck Custom Android Manifest in Project Settings.)

For projects that use the XR Interaction Toolkit, copy Assets/TLab and configure the project according to README.md, and it should work with other projects (2022.1.*).

I will release the Oculus Integration-compatible version as soon as it is completed. So please wait a little.

The TLabWebViewVR repository cannot be updated immediately for the reason that the texture rendering process is being updated. So, please refer to this sample.

sample repository for unity 2022

Please let me know if it doesn't work.

TLabAltoh commented 1 year ago

@aequivalent2 In the sample for 2022, TLabWebViewXRInputListener.cs is modified to use XRRayInteractor. This is different from the XR Interaction Toolkit sample created in this repository, but it is a more correct implementation, so please use it as a reference. I'll get this repository to reflect this change as soon as possible.

TREEANA commented 1 year ago

Thank you for responding, However, if I uncheck 'Custom Android Manifest in Project Settings', won't this cause issues with controller recognition and internet connectivity when manipulating a WebView on the Quest 2? I recall a past experience where, after unchecking 'Custom Android Manifest in Project Settings', I successfully built the app on Quest 2, but couldn't connect to the internet within the app, leading to a 'net::ERR_CACHE_MISS android' error, and the controller wasn't recognized either.

aequivalent2 commented 1 year ago

@TLabAltoh i will test it tomorrow thanks for the fast answers

TLabAltoh commented 1 year ago

In my environment, when OpenXR was specified as the plugin provider, similar network error occurred. It was due to the fact that the OpenXR plugin was forcibly deleting the content defined in manifest. Therefore, you need to specify Oculus as the plugin provider instead of OpenXR (I did not mention this important thing earlier!).

https://forum.unity.com/threads/unity-removes-android-permission-internet-in-the-build-apk-after-build-is-completed.1466654/

As for the issue with the controller not recognizing it, I have not been able to reproduce it this time. (but I have faced similar problems with XR Interaction Tolkit in the past. I just can't remember what caused it ...)

Anyway, I needed to make TLabWebView compatible with 2022, so I made some changes to the script in the sample. the sample started in the VR template, so I think it will be helpful.

TLabAltoh commented 1 year ago

I have corrected an error in my explanation yesterday about the cause of the build error. Creating an Android Custom Manifest was not the cause of the problem. The cause of the problem was the contents of the Android Custom Manifest.

The following is an Android Custom Manifest that was running on Unity 2021.1.*.

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto">
  <application android:label="@string/app_name" android:icon="@mipmap/app_icon" 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.LAUNCHER" />
      </intent-filter>
    </activity>
    <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="false" />
    <meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only" />
  </application>

    <!-- For Unity-WebView Add this -->
    <application android:allowBackup="true"/>
    <application android:supportsRtl="true"/>
    <application android:hardwareAccelerated="true"/>
    <application android:usesCleartextTraffic="true"/>

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.MICROPHONE" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.microphone" />
    <!-- For Unity-WebView -->

  <uses-feature android:name="android.hardware.vr.headtracking" android:version="1" android:required="true" />
</manifest>

The following parts were causing the problem and need to be removed in Unity 2022.1.*.

<!-- For Unity-WebView Add this -->
<application android:allowBackup="true"/>
<application android:supportsRtl="true"/>
<application android:hardwareAccelerated="true"/>
<application android:usesCleartextTraffic="true"/>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.MICROPHONE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.microphone" />
<!-- For Unity-WebView -->

If these items are excluded from the Android Custom Manifest, they will be added in the post-process at build time.

Therefore, it is not necessary to create an Android Custom Manifest after Unity 2022.1.*.

The following is a list of errors related to Android Custom Manifest and their countermeasures.

NullReferenceException: Object reference not set to an instance of an object AndroidManifest.SetHardwareAccelerated (System.Boolean enabled)

cause

Some contents of Android Custom Manifest shown in the sample of 2021.1.* were causing problems.

solution

Do not create Android Custom Manifest or exclude the following from the sample shown in 2021.1.*

<!-- For Unity-WebView Add this -->
<application android:allowBackup="true"/>
<application android:supportsRtl="true"/>
<application android:hardwareAccelerated="true"/>
<application android:usesCleartextTraffic="true"/>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.MICROPHONE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.microphone" />
<!-- For Unity-WebView -->

net::ERR_CACHE_MISS

cause

Probably due to the OpenXR plugin, the following items were forcibly removed from the Android Manifest during build. reference

<uses-permission android:name="android.permission.INTERNET" />

solution

Using Oculus as XR Plug-in Provider

TREEANA commented 1 year ago

Thank you ! I excluded Android Custom Manifest like below image I can build the file.

However, I'm still encountering the 'net::ERR_CACHE_MISS' issue, and the Quest 2's controller is not being recognized in the built app. Does using Oculus as an XR Plug-in Provider mean something like what's depicted in the image below? image

The code I've been working on can be found at: https://github.com/TLabAltoh/TLabWebViewVR/tree/master/Assets/TLab.

Sorry for the repeated question.

TLabAltoh commented 1 year ago

image Please set up as shown in the picture. The code in this repository will not work correctly with Unity 2022, so clone the sample for Unity 2022 and copy the Assets/TLab from the cloned repository.

(Latest Version) Asset Migration Tutorial

Sample Repository for Unity 2022

TREEANA commented 1 year ago

Thank you. The tutorial video was very helpful. The apk is well built, and the internet connection is smooth.

However, I have a few questions.

First, while I can use the Oculus Quest 2 controller to scroll through YouTube, I can't use it to perform click events, such as clicking a virtual keyboard to enter data. Is there an additional setting I need to adjust?

Second, the previous user interface had a search input feature, which allowed me to use a keyboard to access not only YouTube but also other websites like Google. Has this UI been removed?

image

TLabAltoh commented 1 year ago

Is it only the keyboard that is not responding to clicks? I will check this once as it is an area I did not check when I created the sample.

As for the search bar, I removed it once to simplify the WebView prefab, but I will add it again as a sample.

TREEANA commented 1 year ago

I've noticed that not only the keyboard but also the clicks which use A and B controller's button are not responding in the built app. Thanks reupdated search bar UI, will you update the UI to TLabWebViewVR-OculusIntegration-2022 GitHub?

TLabAltoh commented 1 year ago

Sorry for the late reply .... I had added the search bar to the sample repository.

Add Search Bar Sample (Both Oculus Integration and XRToolkit)

a

About the controller not responding to the UI

WebView cannot be operated with the A and B buttons because those inputs are not registered in the sample configuration.

b

The green line in the picture shows the assignment of the controller input to WebView, so if you add the A and B buttons here, the A and B buttons should work for WebView as well ...

As for the virtual keyboard, I was able to operate it using the A and B buttons in my environment.

In Oculus Integration, the UI input is managed by this class, so checking here may solve the problem

TREEANA commented 1 year ago

Thank you, it's working correctly. However, despite updating TLabWebViewVR-GitHub, the TLabWebViewVR located in OculusIntegration-2022Assets/TLab/TLabWebViewVR does not have a search bar UI. Could you please check this?

TLabAltoh commented 1 year ago

Regarding the issue of the app crashing on startup, I have tried to solve this problem, but I still do not know the exact cause. I am not sure if this will work, but try deleting the build cache and trying to build again.

root/Library/Bee <-- Delete this

I forgot to integrate the search bar into the prefab. I'm pushing it now.

TLabAltoh commented 1 year ago

Repository has been updated. It is now available.

TREEANA commented 1 year ago

It works!

image

Thank you very much for accommodating my requests so far.