Android构建失败 - FormatException

时间:2018-05-05 06:26:54

标签: android unity3d android-build

从Unity 2018.1.something切换到2018.2.0.b3后,我无法再为Android构建,我得到:

  

FormatException:输入字符串的格式不正确

在切换到最新测试版之前,我能够创建一个没有任何问题的构建(尽管不是使用gradle,而是使用内部构建系统)。有没有人遇到过这个问题和/或有人可以帮我解决这个问题吗?

这是我收到的全部信息:

FormatException: Input string was not in a correct format.
System.Version+VersionResult.SetFailure (System.Version+ParseFailureKind failure, System.String argument) (at <e1a80661d61443feb3dbdaac88eeb776>:0)
System.Version.TryParseComponent (System.String component, System.String componentName, System.Version+VersionResult& result, System.Int32& parsedComponent) (at <e1a80661d61443feb3dbdaac88eeb776>:0)
System.Version.TryParseVersion (System.String version, System.Version+VersionResult& result) (at <e1a80661d61443feb3dbdaac88eeb776>:0)
System.Version.Parse (System.String input) (at <e1a80661d61443feb3dbdaac88eeb776>:0)
System.Version..ctor (System.String version) (at <e1a80661d61443feb3dbdaac88eeb776>:0)
UnityEditor.Android.Utils.ParseVersion (System.String version) (at <a03b4d5bdb8646db9fef40240e67bcbf>:0)
UnityEditor.Android.AndroidComponentProperties.get_PackageRevision () (at <a03b4d5bdb8646db9fef40240e67bcbf>:0)
UnityEditor.Android.AndroidComponentProperties.GetPackageRevision (System.String directory) (at <a03b4d5bdb8646db9fef40240e67bcbf>:0)
UnityEditor.Android.AndroidSDKTools.BuildToolsVersion () (at <a03b4d5bdb8646db9fef40240e67bcbf>:0)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK+SDKBuildToolsDetector.GetVersion (UnityEditor.Android.AndroidSDKTools sdkTools, UnityEditor.Android.AndroidJavaTools javaTools) (at <a03b4d5bdb8646db9fef40240e67bcbf>:0)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK+SDKComponentDetector.Detect (UnityEditor.Android.AndroidSDKTools sdkTools, UnityEditor.Android.AndroidJavaTools javaTools, System.Version minVersion, UnityEditor.Android.PostProcessor.ProgressHandler onProgress) (at <a03b4d5bdb8646db9fef40240e67bcbf>:0)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.EnsureSDKComponentVersion (UnityEditor.Android.AndroidJavaTools javaTools, System.Version minVersion, UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK+SDKComponentDetector detector) (at <a03b4d5bdb8646db9fef40240e67bcbf>:0)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.EnsureSDKComponentVersion (UnityEditor.Android.AndroidJavaTools javaTools, System.Int32 minVersion, UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK+SDKComponentDetector detector) (at <a03b4d5bdb8646db9fef40240e67bcbf>:0)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <a03b4d5bdb8646db9fef40240e67bcbf>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <a03b4d5bdb8646db9fef40240e67bcbf>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PrepareForBuild (UnityEditor.BuildOptions options, UnityEditor.BuildTarget target) (at <a03b4d5bdb8646db9fef40240e67bcbf>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PrepareForBuild (UnityEditor.BuildOptions options, UnityEditor.BuildTarget target) (at <a03b4d5bdb8646db9fef40240e67bcbf>:0)
UnityEditor.PostprocessBuildPlayer.PrepareForBuild (UnityEditor.BuildOptions options, UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:106)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

4 个答案:

答案 0 :(得分:0)

这可能是因为您的“目标API”设置为“自动(最高安装)”。如果您将Android P安装为最高API,则应将Target API设置更改为其他设置。我将我的设置为“Android 8.1(奥利奥)”。

答案 1 :(得分:0)

我正在使用Unity版本2019.1.9f1。收到此错误后,我一直在寻找正确的解决方案,其中一些告诉您使用正确的Format编码更改Unity系统文件。但是在进行系统文件编辑之前,只需重新启动我的macOS和Unity3D,即可正常运行。

答案 2 :(得分:0)

我通过更改设备插入的USB端口来解决此问题。

答案 3 :(得分:0)

从任务管理器中杀死 adb.exe 进程并重试