Unity Android 生成错误:必须使用 ScriptableObject.CreateInstance 方法实例化 GooglePlayServices.CommandLineDialog

Unity Android build error: GooglePlayServices.CommandLineDialog must be instantiated using the ScriptableObject.CreateInstance method

提问人:Batman 提问时间:11/10/2023 更新时间:11/13/2023 访问量:63

问:

几天来,我一直在为这个问题而苦苦挣扎。所以我的项目很好,然后突然让 Android 构建开始失败(iOS 构建仍然很好)

我使用命令行构建项目(这是项目的要求)

生成过程不会停止或崩溃。这就像永远待定一样。

最新的日志是这样的:

GooglePlayServices.CommandLineDialog must be instantiated using the ScriptableObject.CreateInstance method instead of new CommandLineDialog.
UnityEngine.StackTraceUtility:ExtractStackTrace () (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/StackTrace.cs:37)
UnityEngine.ScriptableObject:.ctor () (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/ScriptableObject.bindings.cs:19)
UnityEditor.EditorWindow:.ctor () (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorWindow.cs:1187)
GooglePlayServices.TextAreaDialog:.ctor () (at Z:/tmp/tmp.Zw8JRhK8tU/third_party/unity/unity_jar_resolver/source/AndroidResolver/src/TextAreaDialog.cs:69)
GooglePlayServices.CommandLineDialog:.ctor () (at Z:/tmp/tmp.Zw8JRhK8tU/third_party/unity/unity_jar_resolver/source/AndroidResolver/src/CommandLineDialog.cs:168)
GooglePlayServices.CommandLineDialog:CreateCommandLineDialog (string) (at Z:/tmp/tmp.Zw8JRhK8tU/third_party/unity/unity_jar_resolver/source/AndroidResolver/src/CommandLineDialog.cs:189)
GooglePlayServices.GradleResolver:GradleResolution (string,string,bool,bool,System.Action`1<System.Collections.Generic.List`1<Google.JarResolver.Dependency>>) (at Z:/tmp/tmp.Zw8JRhK8tU/third_party/unity/unity_jar_resolver/source/AndroidResolver/src/GradleResolver.cs:365)
GooglePlayServices.GradleResolver:DoResolutionUnsafe (string,bool,System.Action) (at Z:/tmp/tmp.Zw8JRhK8tU/third_party/unity/unity_jar_resolver/source/AndroidResolver/src/GradleResolver.cs:928)
GooglePlayServices.GradleResolver/<DoResolution>c__AnonStorey7:<>m__0 () (at Z:/tmp/tmp.Zw8JRhK8tU/third_party/unity/unity_jar_resolver/source/AndroidResolver/src/GradleResolver.cs:819)
Google.RunOnMainThread:ExecuteNext () (at Z:/tmp/tmp.cHLLGXXRL4/third_party/unity/unity_jar_resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:486)
Google.RunOnMainThread:<ExecuteAllUnnested>m__1 () (at Z:/tmp/tmp.cHLLGXXRL4/third_party/unity/unity_jar_resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:536)
Google.RunOnMainThread:RunAction (System.Action) (at Z:/tmp/tmp.cHLLGXXRL4/third_party/unity/unity_jar_resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:343)
Google.RunOnMainThread:ExecuteAllUnnested (bool) (at Z:/tmp/tmp.cHLLGXXRL4/third_party/unity/unity_jar_resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:530)
Google.RunOnMainThread:TryExecuteAll () (at Z:/tmp/tmp.cHLLGXXRL4/third_party/unity/unity_jar_resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:500)
GooglePlayServices.PlayServicesResolver:PollManualResetEvent (System.Threading.ManualResetEvent) (at Z:/tmp/tmp.Zw8JRhK8tU/third_party/unity/unity_jar_resolver/source/AndroidResolver/src/PlayServicesResolver.cs:1624)
GooglePlayServices.PlayServicesResolver:ResolveSync (bool,bool) (at Z:/tmp/tmp.Zw8JRhK8tU/third_party/unity/unity_jar_resolver/source/AndroidResolver/src/PlayServicesResolver.cs:1647)
GooglePlayServices.PlayServicesResolver:OnPostProcessScene () (at Z:/tmp/tmp.Zw8JRhK8tU/third_party/unity/unity_jar_resolver/source/AndroidResolver/src/PlayServicesResolver.cs:1201)
System.Reflection.RuntimeMethodInfo:Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo)
System.Reflection.MethodBase:Invoke (object,object[])
UnityEditor.Build.BuildPipelineInterfaces/AttributeCallbackWrapper:OnProcessScene (UnityEngine.SceneManagement.Scene,UnityEditor.Build.Reporting.BuildReport) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:191)
UnityEditor.Build.BuildPipelineInterfaces/<>c__DisplayClass17_0:<OnSceneProcess>b__1 (UnityEditor.Build.IProcessSceneWithReport) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:447)
UnityEditor.Build.BuildPipelineInterfaces:InvokeCallbackInterfacesPair<UnityEditor.Build.IProcessScene, UnityEditor.Build.IProcessSceneWithReport> (System.Collections.Generic.List`1<UnityEditor.Build.IProcessScene>,System.Action`1<UnityEditor.Build.IProcessScene>,System.Collections.Generic.List`1<UnityEditor.Build.IProcessSceneWithReport>,System.Action`1<UnityEditor.Build.IProcessSceneWithReport>,bool) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:402)
UnityEditor.Build.BuildPipelineInterfaces:OnSceneProcess (UnityEngine.SceneManagement.Scene,UnityEditor.Build.Reporting.BuildReport) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:445)
UnityEditor.BuildPipeline:BuildAssetBundles (string,UnityEditor.BuildAssetBundleOptions,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline.bindings.cs:571)
UnityEditor.BuildPipeline:BuildAssetBundles (string,UnityEditor.BuildAssetBundleOptions,UnityEditor.BuildTarget) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline.bindings.cs:560)

我试图在我的项目中找到调用GooglePlayServices.CommandLineDialog的方法,但没有找到。此方法调用可能属于某些无法访问的第三方插件库或依赖项。

我不知道为什么事情开始失败,因为自上次成功构建以来没有进行任何更改。

Android unity-游戏引擎 google-play-services

评论


答:

1赞 ifeel 11/13/2023 #1

我有同样的问题。然后,我在“Assets/External Denpendency Manager/Android Resolver/Settings”中关闭了“Enable Resolution On Build”。它有效。 但是为什么? 我知道这不是最终的决议。

评论

0赞 Batman 11/13/2023
是的,这听起来不对。关闭它可能会使构建过程成功,但我担心构建在某些涉及外部依赖性的地方无法正常工作。
0赞 ifeel 11/14/2023
我认为这不是错误的关键点。首先备份您的项目,以确保您可以成功构建 Android 项目。后续操作将重新排列本地 Android 依赖包。打开 Unity、Assets/External Denpendency Manager/Android Resolver/Force Reslove,正常情况下会停止并显示成功,但现在不会停止。我不知道为什么。如果某天某个 SDK 需要升级,则必须执行 Reslove。如果不能停下来的问题能够解决,我相信以上问题都会得到解决。@Batman