juicycleff / flutter-unity-view-widget

Embeddable unity game engine view for Flutter. Advance demo here https://github.com/juicycleff/flutter-unity-arkit-demo
BSD 3-Clause "New" or "Revised" License
2.13k stars 518 forks source link

Project with path 'xrmanifest.androidlib' could not be found in project ':unityLibrary'. #844

Closed dibenedetto closed 1 year ago

dibenedetto commented 1 year ago

Describe the bug Build fails with error: "Project with path 'xrmanifest.androidlib' could not be found in project ':unityLibrary'".

To Reproduce Steps to reproduce the behavior: Include a Unity project which uses the XR management 4.4.0.

Expected behavior Successful build and run.

Screenshots No screenshot needed.

Unity (please complete the following information):

Smartphone (please complete the following information): It fails on build.

Additional context No additional info.

timbotimbo commented 1 year ago

[UPDATE] See my newer answer in the comments below.

The rest of this comment is outdated.

[Original comment] You will likely need to edit your gradle files to include this file. I haven't tested this yet, but it will probably be something like this:

android/settings.gradle

include ":xrmanifest.androidlib"
project(":xrmanifest.androidlib").projectDir = file("./unityLibrary/xrmanifest.androidlib")

android/app/build.gradle

  dependencies {
+        implementation project(':xrmanifest.androidlib')
     }
dibenedetto commented 1 year ago

You will likely need to edit your gradle files to include this file. I haven't tested this yet, but it will probably be something like this:

android/settings.gradle

include ":xrmanifest.androidlib"
project(":xrmanifest.androidlib").projectDir = file("./unityLibrary/xrmanifest.androidlib")

android/app/build.gradle

  dependencies {
+        implementation project(':xrmanifest.androidlib')
     }

thanks, but it fails with the same error :(

AdrienGannerie commented 1 year ago

Did you find a solution ? I have the same issue.

khangpt commented 1 year ago

me too T_T

khangpt commented 1 year ago

I'm not sure this is a solution to make the build is successful. But when I make same with @timbotimbo said, also comment out this line "implementation project('xrmanifest.androidlib')" in unityLibrary/build.gradle ==> flutter run is OK.

But, when run android device, I got below: Screenshot_20230718_160222

This is log on my console:

Screenshot 2023-07-18 at 16 02 42

This is how I'm using the widget in Flutter:

Screenshot 2023-07-18 at 16 02 48

Hope anybody can help

timbotimbo commented 1 year ago

Just made a project to test this out.

Apparenty xrmanifest.androidlib is a new folder and not a file like I expected, located in /unityLibrary.

Adding a line to android/settings.gradle made it compile again for me.

  include ":unityLibrary"
  project(":unityLibrary").projectDir = file("./unityLibrary")

+ include ':unityLibrary:xrmanifest.androidlib'

I got this from /unity/<project folder>/Builds/settings.gradle which was generated by Unity. The builds folder is the original build created on an export and parts of that get moved to android/unityLibrary for this plugin.

While testing this ARFoundation ran into issue #836, the error with mUnityplayer in @khangpt's screenshot above. This means it is likely broken (for now) starting with the Unity versions:

dibenedetto commented 1 year ago
include ':unityLibrary:xrmanifest.androidlib'

this, combined with that, apparently solved the problem: the application is built and it runs on the device, but the AR camera is not open and this error comes out:

E/Unity   (  596): AndroidJavaException: java.lang.NoSuchFieldError: no "Ljava/lang/Object;" field "mUnityPlayer" in class "Lcom/hyperversexr/hyperversexr/MainActivity;" or its superclasses
E/Unity   (  596): java.lang.NoSuchFieldError: no "Ljava/lang/Object;" field "mUnityPlayer" in class "Lcom/hyperversexr/hyperversexr/MainActivity;" or its superclasses
E/Unity   (  596):  at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
E/Unity   (  596):  at com.unity3d.player.UnityPlayer.-$$Nest$mnativeRender(Unknown Source:0)
E/Unity   (  596):  at com.unity3d.player.UnityPlayer$C$a.handleMessage(Unknown Source:122)
E/Unity   (  596):  at android.os.Handler.dispatchMessage(Handler.java:102)
E/Unity   (  596):  at android.os.Looper.loop(Looper.java:233)
E/Unity   (  596):  at com.unity3d.player.UnityPlayer$C.run(Unknown Source:24)
E/Unity   (  596):   at UnityEngine.AndroidJNISafe.CheckException () [0x00091] in \home\bokken\build\output\unity\unity\Modules\AndroidJNI\AndroidJNISafe.cs:24 
E/Unity   (  596):   at UnityEngine.AndroidJNISafe.GetFieldID (System.IntPtr clazz, System.String name, System.String sig) [0x0000e] in \home\bokken\build\output\unity\unity\Modules\AndroidJNI\AndroidJNISafe.

is that related to the original issue?

timbotimbo commented 1 year ago

That is a different breaking change in Unity, the last section with mUnityplayer I mentioned above.

dibenedetto commented 1 year ago

That is a different breaking change in Unity, the last section with mUnityplayer I mentioned above.

oh, that's ok, so i'll close this issue, thanks so much.

dibenedetto commented 1 year ago

That is a different breaking change in Unity, the last section with mUnityplayer I mentioned above.

anyway, on my device, using version 2022.2.21f1 i can see the 3d scene (just a cube) but on a black background, e.g., no camera feedback.

with version 2022.2.0f1 it fails to build.

any idea on that?

khangpt commented 1 year ago

That is a different breaking change in Unity, the last section with mUnityplayer I mentioned above.

anyway, on my device, using version 2022.2.21f1 i can see the 3d scene (just a cube) but on a black background, e.g., no camera feedback.

with version 2022.2.0f1 it fails to build.

any idea on that?

I think you should try to enable camera permission on your device first. Hope this help

JonFaull commented 11 months ago

Any one have any solutions to this?