Unity打安卓包 Android 所有錯誤解決方案大全(幾乎囊括所有打包錯誤 )


Unity打包出錯解決方案


本文提供全流程,中文翻譯。

Chinar 堅持將簡單的生活方式,帶給世人!

(擁有更好的閱讀體驗 —— 高分辨率用戶請根據需求調整網頁縮放比例)



Chinar —— 心分享、心創新!

助力快速解決 Unity 打包中常見錯誤

給新手節省寶貴的時間,避免采坑!



1

Change Name —— 未設置修改包名 / 公司名 / 項目名


由於未設置修改 包名 / 公司名 / 項目名

導致報錯,最為簡單

具體錯誤字符:
UnityException: Package Name has not been set up correctly
Please set the Package Name in the Player Settings. The value must follow the convention 'com.YourCompanyName.YourProductName' and can contain alphanumeric characters and underscore.
Each segment must not start with a numeric character or underscore.
Error building Player: 2 errors
UnityEditor.BuildPlayerWindow+BuildMethodException: 3 errors
  at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) [0x0020e] in
Build completed with a result of 'Failed'
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

這里寫圖片描述
這里寫圖片描述

解決方案:

更改 公司名 / 包名 / 項目名
舉個栗子黑白88
這里寫圖片描述——這里寫圖片描述


2

SDK Tools —— Unity版本低,需要安卓工具版本也低些


一般高版本的2017.2-2017.3都不會報此錯誤

常見於 5.X 版本


具體錯誤字符:
Error:Invalid command android<br>UnityEditor.HostView:OnGUI()
CommandInvokationFailure: Unable to list target platforms. 
Please make sure the android sdk path is correct. See the Console for more details. 
Error building Player: CommandInvokationFailure: 
Unable to list target platforms. 
Please make sure the android sdk path is correct. See the Console for more details. 

這里寫圖片描述
這里寫圖片描述

解決方案:

更換安卓工具包,至較低的版本

1. 點擊下載 —— 安卓工具包 24 版本

2.解壓后替換 安卓 SDK 中的 Tools 文件夾

3.然后重新打包,即可成功!!!


反之:如果 Unity 版本高,同樣需要換成高版本的 安卓 SDK Tools
舉個栗子黑白88
這里寫圖片描述


3

AR Vuforia Android TV —— Vuforia AR 發開中,打包安卓報錯


由於 Vuforia 不支持 Android TV ,導致報錯

具體錯誤字符:
Vuforia does not support Android TV. Please disable the Android TV compatibility in the Player Settings.

UnityEngine.Debug:LogError(Object)
BuildObserver:OnPreprocessBuild(BuildTarget, String)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
Error building Player: Vuforia does not support Android TV. Please disable the Android TV compatibility in the Player Settings.
Build completed with a result of 'Failed'
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
  at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) [0x0020e] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:181 
  at UnityEditor.BuildPlayerWindow.CallBuildMethods (Boolean askForBuildLocation, BuildOptions defaultBuildOptions) [0x00065] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:88 
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

這里寫圖片描述

解決方案:

所以需要在 Player Setting 中關閉該選項

即可成功打包工程
舉個栗子黑白88
這里寫圖片描述


4

Quote UnityEditor —— 腳本引用 UnityEditor,無法打包


打包項目/工程時報錯

Unity Asset 目錄中,如果腳本中引用了 UnityEditor

那么該腳本就應該放在 Editor 文件夾下 ( 如果沒有,就新建一個名為 Editor 的文件夾)

具體錯誤字符:
Assets/CreateGuanJians.cs(4,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing an assembly reference?
Error building Player because scripts had compiler errors
Build completed with a result of 'Failed'
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
  at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) [0x0020e] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:181 
  at UnityEditor.BuildPlayerWindow.CallBuildMethods (Boolean askForBuildLocation, BuildOptions defaultBuildOptions) [0x00065] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:88 
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()

這里寫圖片描述

解決方案:

將引用有 UnityEditor 的腳本放在 Editor 文件夾下

( 如果沒有,就新建一個名為 Editor 的文件夾)

即可成功打包工程
舉個栗子黑白88
這里寫圖片描述


5

Update —— 不斷更新中…….最后匯集所有報錯指南

錯誤不斷更新中…….最后匯集所有報錯指南

請您惠存,支持 Chinar


支持

May Be —— 搞開發,總有一天要做的事!


擁有自己的服務器,無需再找攻略!

Chinar 提供一站式教程,閉眼式創建!

為新手節省寶貴時間,避免采坑!


先點擊領取 —— 阿里全產品優惠券 (享受最低優惠)


1 —— 雲服務器超全購買流程 (新手必備!)

2 —— 阿里ECS雲服務器自定義配置 - 購買教程(新手必備!)

3—— Windows 服務器配置、運行、建站一條龍 !

4 —— Linux 服務器配置、運行、建站一條龍 !





技術交流群:806091680 ! Chinar 歡迎你的加入


END

本博客為非營利性個人原創,除部分有明確署名的作品外,所刊登的所有作品的著作權均為本人所擁有,本人保留所有法定權利。違者必究

對於需要復制、轉載、鏈接和傳播博客文章或內容的,請及時和本博主進行聯系,留言,Email: ichinar@icloud.com

對於經本博主明確授權和許可使用文章及內容的,使用時請注明文章或內容出處並注明網址


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM