Unity3D安卓出包报错

今天又遇到了在安卓出包时,直接报错了两个错误,报错信息分别如下:

Installation failed with the following output:
pkg: /data/local/tmp/Package.apk

UnityException: Unable to install APK!
Installation failed. See the Console for details.

两个错误信息的详细描述如下:

1
2
3
4
5
6
7
8
Installation failed with the following output:
pkg: /data/local/tmp/Package.apk

Failure [INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE]

5194 KB/s (24217926 bytes in 4.553s)

UnityEditor.HostView:OnGUI()
1
2
3
4
5
6
7
8
9
10
UnityException: Unable to install APK!
Installation failed. See the Console for details.
UnityEditor.Android.PostProcessAndroidPlayer.ShowErrDlgAndThrow (System.String title, System.String message, System.Exception ex)
UnityEditor.Android.PostProcessAndroidPlayer.ShowErrDlgAndThrow (System.String title, System.String message)
UnityEditor.Android.PostProcessAndroidPlayer.UploadAndStartPlayer (System.String manifestName, System.String stagingArea, UnityEditor.Android.AndroidDevice device, System.String packageName, Boolean developmentPlayer, Boolean retryUpload)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcessInternal (System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (BuildPostProcessArgs args)
UnityEditor.PostprocessBuildPlayer.Postprocess (BuildTarget target, System.String installPath, System.String companyName, System.String productName, Int32 width, Int32 height, System.String downloadWebplayerUrl, System.String manualDownloadWebplayerUrl, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:316)
UnityEditor.HostView:OnGUI()

安卓出包时出现这个bug的原因,是因为当前项目的包名和手机上已安装的某个app包名相同,导致了冲突。解决办法就是直接将手机上导致冲突的app直接卸载掉就OK了。
这个bug已经遇到过多次了,是因为我在真机测试时装了一个测试程序,然后过了一段时间后,PlayerSettings中的某些设置被改变了,没有删除安装的测试包,就直接Build And Run,然后就报上述的错误了。
把这个Bug在博客里记录一下,加深点印象,顺便分享出去,希望能帮到遇到同样问题的朋友。

如果本文有错误之处还请帮忙指出。