googlesamples / unity-jar-resolver

Unity plugin which resolves Android & iOS dependencies and performs version management
Other
1.22k stars 339 forks source link

Google.VersionHandlerImpl bootstrap disabled #501

Closed root-ansh closed 2 years ago

root-ansh commented 2 years ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the question here:

I want to use a 3rd party unity package that requires a unity jar resolver to resolve its android dependencies. I do the following steps but the script doesn't seem to get enabled on its own:

  1. open unity editor via cmd with gvh disabled flag : /Applications/Unity/Hub/Editor/2022.1.0b6/Unity.app/Contents/MacOS/Unity -gvh_disable
  2. create a unity 2d project
  3. import the original library via assets>import custom package
  4. import the unity-jar-resolver via assets>import custom package
  5. switch the build environment to android.

I get this log in my console.

Google.VersionHandlerImpl bootstrap disabled
UnityEngine.Debug:Log (object)
Google.VersionHandler:.cctor () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandler/src/VersionHandler.cs:116)
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes (System.Type[]) (at /Users/bokken/buildslave/unity/build/Editor/Mono/EditorAssemblies.cs:145)

I tried to quit everything and then reopen the project via command line and the next time i get this log as well as some more logs:

Google.VersionHandlerImpl bootstrap disabled
UnityEngine.Debug:Log (object)
Google.VersionHandler:.cctor () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandler/src/VersionHandler.cs:116)
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes (System.Type[]) (at /Users/bokken/buildslave/unity/build/Editor/Mono/EditorAssemblies.cs:145)
Non-secure network connections disabled in Player Settings
System.Reflection.MethodBase:Invoke (object,object[])
Google.PortableWebRequest:StartRequest (Google.PortableWebRequest/HttpMethod,string,System.Collections.Generic.IDictionary`2<string, string>,UnityEngine.WWWForm) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/PortableWebRequest.cs:508)
Google.PortableWebRequest/<StartRequestOnMainThread>c__AnonStorey6:<>m__C () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/PortableWebRequest.cs:458)
Google.RunOnMainThread:ExecuteNext () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:486)
Google.RunOnMainThread:<ExecuteAllUnnested>m__12 () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:536)
Google.RunOnMainThread:RunAction (System.Action) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:343)
Google.RunOnMainThread:ExecuteAllUnnested (bool) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:530)
Google.RunOnMainThread:ExecuteAll () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:512)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
Job failed with exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Insecure connection not allowed
  at (wrapper managed-to-native) UnityEngine.Networking.UnityWebRequest.BeginWebRequest(UnityEngine.Networking.UnityWebRequest)
  at UnityEngine.Networking.UnityWebRequest.SendWebRequest () [0x00001] in /Users/bokken/buildslave/unity/build/Modules/UnityWebRequest/Public/UnityWebRequest.bindings.cs:288 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <4a132ca6e2db43bdb975b154d6271b43>:0 
   --- End of inner exception stack trace ---
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00083] in <4a132ca6e2db43bdb975b154d6271b43>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <4a132ca6e2db43bdb975b154d6271b43>:0 
  at Google.PortableWebRequest.StartRequest (Google.PortableWebRequest+HttpMethod method, System.String url, System.Collections.Generic.IDictionary`2[TKey,TValue] headers, UnityEngine.WWWForm form) [0x0019e] in /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/PortableWebRequest.cs:508 
  at Google.PortableWebRequest+<StartRequestOnMainThread>c__AnonStorey6.<>m__C () [0x00000] in /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/PortableWebRequest.cs:458 
  at Google.RunOnMainThread.ExecuteNext () [0x0003d] in /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:486 
UnityEngine.Debug:LogError (object)
Google.RunOnMainThread:ExecuteNext () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:488)
Google.RunOnMainThread:<ExecuteAllUnnested>m__12 () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:536)
Google.RunOnMainThread:RunAction (System.Action) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:343)
Google.RunOnMainThread:ExecuteAllUnnested (bool) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:530)
Google.RunOnMainThread:ExecuteAll () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:512)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions () (at /Users/bokken/buildslave/unity/build/Editor/Mono/EditorApplication.cs:359)

previously I was using another version of unity editor (which I do not remember, it was on another m1 laptop that I had to get replaced) and i was able to get this plugin to work , after doing similar steps , but on this device/unity version, it doesn't work. Can you please help?

google-oss-bot commented 2 years ago

This issue does not seem to follow the issue template. Make sure you provide all the required information.

root-ansh commented 2 years ago

can @google-oss-bot or anyone else tell me what other information I can provide? I followed the template and entered details accordingly. If something is left , please let me know

DellaBitta commented 2 years ago

Hi @root-ansh,

The original log of Google.VersionHandlerImpl bootstrap disabled is expected. This is reporting that the -gvh_disable command line argument has been enabled.

Could you describe more about why you're using the -gvh_disable flag on the command line? Are you following these instructions on how to export your own plugin?

Thanks!

root-ansh commented 2 years ago

@DellaBitta Hi, thanks for the quick response. Yes, the plugin is created by the company I work with, and I am trying to import it into a sample project in order to make further changes to it.

My first goal is to import the library plugin correctly in a sample project. the library depends on certain android system libraries like appcompat-1.3.1.aar and fragments.aar for which i was using this plugin

chkuang-g commented 2 years ago

Hi @root-ansh

-gvh_disable will pretty much prevent VersionHandler to boostrap VersionHandlerImp. And VersionHandlerImp is required to enable AndroidResolver.dll when you import EDM4U for the first time.

https://github.com/googlesamples/unity-jar-resolver/blob/master/source/VersionHandler/src/VersionHandler.cs#L115

So my understanding is that you used -gvh_disable because you do not want the Version Handling aspect of EDM4U to kick-in but still want to use Android Resolver to download and resolve Android libraries to your sample project, is this correct?

That...sounds like an odd use-case. What issue would you experience if you just remove -gvh_disable from your launch command?

root-ansh commented 2 years ago

I created a test project to test this without -gvh_disable.

after adding jar resolver package:

Non-secure network connections disabled in Player Settings
System.Reflection.MethodBase:Invoke (object,object[])
Google.PortableWebRequest:StartRequest (Google.PortableWebRequest/HttpMethod,string,System.Collections.Generic.IDictionary`2<string, string>,UnityEngine.WWWForm) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/PortableWebRequest.cs:508)
Google.PortableWebRequest/<StartRequestOnMainThread>c__AnonStorey6:<>m__C () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/PortableWebRequest.cs:458)
Google.RunOnMainThread:ExecuteNext () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:486)
Google.RunOnMainThread:<ExecuteAllUnnested>m__12 () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:536)
Google.RunOnMainThread:RunAction (System.Action) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:343)
Google.RunOnMainThread:ExecuteAllUnnested (bool) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:530)
Google.RunOnMainThread:ExecuteAll () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:512)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
Job failed with exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Insecure connection not allowed
  at (wrapper managed-to-native) UnityEngine.Networking.UnityWebRequest.BeginWebRequest(UnityEngine.Networking.UnityWebRequest)
  at UnityEngine.Networking.UnityWebRequest.SendWebRequest () [0x00001] in /Users/bokken/buildslave/unity/build/Modules/UnityWebRequest/Public/UnityWebRequest.bindings.cs:288 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <4a132ca6e2db43bdb975b154d6271b43>:0 
   --- End of inner exception stack trace ---
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00083] in <4a132ca6e2db43bdb975b154d6271b43>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <4a132ca6e2db43bdb975b154d6271b43>:0 
  at Google.PortableWebRequest.StartRequest (Google.PortableWebRequest+HttpMethod method, System.String url, System.Collections.Generic.IDictionary`2[TKey,TValue] headers, UnityEngine.WWWForm form) [0x0019e] in /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/PortableWebRequest.cs:508 
  at Google.PortableWebRequest+<StartRequestOnMainThread>c__AnonStorey6.<>m__C () [0x00000] in /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/PortableWebRequest.cs:458 
  at Google.RunOnMainThread.ExecuteNext () [0x0003d] in /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:486 
UnityEngine.Debug:LogError (object)
Google.RunOnMainThread:ExecuteNext () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:488)
Google.RunOnMainThread:<ExecuteAllUnnested>m__12 () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:536)
Google.RunOnMainThread:RunAction (System.Action) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:343)
Google.RunOnMainThread:ExecuteAllUnnested (bool) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:530)
Google.RunOnMainThread:ExecuteAll () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:512)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions () (at /Users/bokken/buildslave/unity/build/Editor/Mono/EditorApplication.cs:359)

after adding my library and switching the Build-environment to android :

  1. I got a popup asking to enable an external dependency manager.
  2. on checking that, I got another popup trying to download dependencies but failing : image. its logs are :
Running Gradle...

/Users/anshsachdeva/Desktop/no_gvh/Temp/PlayServicesResolverGradle/gradlew --no-daemon -b "/Users/anshsachdeva/Desktop/no_gvh/Temp/PlayServicesResolverGradle/PlayServicesResolver.scripts.download_artifacts.gradle" "-PANDROID_HOME=/Applications/Unity/Hub/Editor/2022.1.0b6/PlaybackEngines/AndroidPlayer/SDK" "-PTARGET_DIR=/Users/anshsachdeva/Desktop/no_gvh/Assets/Plugins/Android" "-PMAVEN_REPOS=" "-PPACKAGES_TO_COPY=com.google.android.gms:play-services-base:17.4.0;androidx.annotation:annotation:1.1.0;androidx.core:core:1.3.2;androidx.viewpager:viewpager:1.0.0;androidx.fragment:fragment:1.2.5;com.google.android.material:material:1.2.1;androidx.appcompat:appcompat:1.2.0;androidx.recyclerview:recyclerview:1.1.0;com.android.installreferrer:installreferrer:2.1" "-PUSE_JETIFIER=0" "-PDATA_BINDING_VERSION=4.0.1"
Executing command: /Users/anshsachdeva/Desktop/no_gvh/Temp/PlayServicesResolverGradle/gradlew --no-daemon -b "/Users/anshsachdeva/Desktop/no_gvh/Temp/PlayServicesResolverGradle/PlayServicesResolver.scripts.download_artifacts.gradle" "-PANDROID_HOME=/Applications/Unity/Hub/Editor/2022.1.0b6/PlaybackEngines/AndroidPlayer/SDK" "-PTARGET_DIR=/Users/anshsachdeva/Desktop/no_gvh/Assets/Plugins/Android" "-PMAVEN_REPOS=" "-PPACKAGES_TO_COPY=com.google.android.gms:play-services-base:17.4.0;androidx.annotation:annotation:1.1.0;androidx.core:core:1.3.2;androidx.viewpager:viewpager:1.0.0;androidx.fragment:fragment:1.2.5;com.google.android.material:material:1.2.1;androidx.appcompat:appcompat:1.2.0;androidx.recyclerview:recyclerview:1.1.0;com.android.installreferrer:installreferrer:2.1" "-PUSE_JETIFIER=0" "-PDATA_BINDING_VERSION=4.0.1"
Reporting analytics data: /androidresolver/resolve/gradle/failed/fetch?unityVersion=2022.1.0b6&unityPlatform=OSXEditor&installSource=unitypackage&version=1.2.169&scope= 'Android Resolver: Gradle Resolve: Tool Extraction Failed'
ERROR: Gradle failed to fetch dependencies.

Failed to run '/Users/anshsachdeva/Desktop/no_gvh/Temp/PlayServicesResolverGradle/gradlew --no-daemon -b "/Users/anshsachdeva/Desktop/no_gvh/Temp/PlayServicesResolverGradle/PlayServicesResolver.scripts.download_artifacts.gradle" "-PANDROID_HOME=/Applications/Unity/Hub/Editor/2022.1.0b6/PlaybackEngines/AndroidPlayer/SDK" "-PTARGET_DIR=/Users/anshsachdeva/Desktop/no_gvh/Assets/Plugins/Android" "-PMAVEN_REPOS=" "-PPACKAGES_TO_COPY=com.google.android.gms:play-services-base:17.4.0;androidx.annotation:annotation:1.1.0;androidx.core:core:1.3.2;androidx.viewpager:viewpager:1.0.0;androidx.fragment:fragment:1.2.5;com.google.android.material:material:1.2.1;androidx.appcompat:appcompat:1.2.0;androidx.recyclerview:recyclerview:1.1.0;com.android.installreferrer:installreferrer:2.1" "-PUSE_JETIFIER=0" "-PDATA_BINDING_VERSION=4.0.1"'
stdout:

stderr:
The operation couldn���t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
exit code: 1

I close that window manually and again try to build and run, and I get a lot of errors (Pastebin link) From the logs, I somewhat understand that the plugin is unable to detect the java path, but am not sure why it does so?

root-ansh commented 2 years ago

Update: I created an empty project and tried to run it on android, it also gives a lot of errors. I am guessing its some issue from the Unity editor itself, reported this to their forum also

DellaBitta commented 2 years ago

Hi @root-ansh,

As you pointed out, the error with the empty project on Apple Silicon seems to be an issue in the Unity editor. Please keep us posted on what they say in response to your post in their forums. We may have others encountering similar issues and we'd like to be able to advise them as best we can. Thanks!

Regarding the other error when switching to Android, the logs point to a lack of configured JDK. You can set the path to your JDK directly in Unity -> Preferences -> External Tools. The "safest" configuration is to use the Open JDK optionally installed with the Unity Editor. It can be installed via Unity Hub through Installs, click on the settings for an editor installation, then Add Modules and enable Android Build Support -> OpenJDK, and if you haven't configured your own Android SDK download, then also enable Android SDK & NDK tools.

I hope this helps!

google-oss-bot commented 2 years ago

Hey @root-ansh. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

root-ansh commented 2 years ago

hi, I was able to get this working with one particular version of unity for apple silicon (2021.2.10f1) without any issues. so I am guessing this is on the unity side itself. thankyou for the help!