2018年1月6日 星期六

隨手札記:Unity-使用WebGL匯出,il2cpp.exe炸裂!


假的!一定是我眼睛業障重!
這麼一長串 error 是要嚇死誰啊。
別擔心,解決方法很簡單。(至少在我這個案例裡)

兩個error訊息分別是
Failed running C:\Program Files\Unity\Editor\Data\il2cpp/build/il2cpp.exe

Exception: C:\Program Files\Unity\Editor\Data\il2cpp/build/il2cpp.exe did not run properly!

這問題似乎炸過世界各地的使用者一輪, Google 結果各種混亂....

研究了兩三個小時、只好崩潰發文詢問。
因為有前輩詢問error的詳細訊息,所以我把整段error放到記事本

....然後就看到有地方怪怪的。

嗯....那些亂碼出現的地方,原本應該是「創作」之類的中文字....

....等等,亂碼?

(默默地把整個專案搬遷到純英文的資料夾)
(再度打開匯出)
(然後就正常地匯出了)

.......全世界都對中文不友善是不是。
中文沒文權啦嗚嗚嗚(躺在地上打滾)

補充一下: il2cpp.exe 顧名思義,是把 IL 語言轉換成C++語言輸出的工具程式
我猜測是因為一些語法的緣故導致程式在讀取路徑時會把英文字(ASCII?)以外的文字炸掉/辨識不能,才導致無法正常使用。

如果有遇到類似問題的朋友,請試試看把整個專案資料夾移動到純英文路徑之下,再重新匯出看看

如果有幫到你,希望可以在下面留個言讓我知道!
(...沒幫助的話也可以留言啦,順便貼上代碼,我看看能不能幫忙。)

8 則留言:

  1. stdout:
    Building libil2cpp.so with AndroidToolChain
    Output directory: C:\Users\HUNG\Downloads\���ڲ��~\Temp\StagingArea\assets\bin\Data\Native\armeabi-v7a
    Cache directory: C:\Users\HUNG\Downloads\���ڲ��~\Library\il2cpp_android_armeabi-v7a\il2cpp_cache

    回覆刪除
    回覆
    1. 碰到一樣的問題!先試試看大神的解決方法!感謝!!

      刪除
    2. 真的改成英文就可以了!!!謝謝!這卡了我好久!

      刪除

  2. stdout:
    Building libil2cpp.so with AndroidToolChain
    Output directory: C:\Users\9447l\spacewar\Temp\StagingArea\assets\bin\Data\Native\armeabi-v7a
    Cache directory: C:\Users\9447l\spacewar\Library\il2cpp_android_armeabi-v7a\il2cpp_cache
    ObjectFiles: 176 of which compiled: 0
    Total compilation time: 214 milliseconds.
    il2cpp.exe didn't catch exception: System.IO.IOException: �ϺЪ��Ŷ������C

    �� System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
    �� System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
    �� NiceIO.NPath.CopyWithDeterminedDestination(NPath absoluteDestination, Func`2 fileFilter)
    �� System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
    �� System.Linq.Buffer`1..ctor(IEnumerable`1 source)
    �� System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
    �� Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet`1 objectFiles, CppToolChainContext toolChainContext)
    �� Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
    �� il2cpp.Program.DoRun(String[] args)
    �� il2cpp.Program.Run(String[] args)
    �� il2cpp.Program.Main(String[] args)
    stderr:

    ���B�z���ҥ~���p: System.IO.IOException: �ϺЪ��Ŷ������C

    �� System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
    �� System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
    �� NiceIO.NPath.CopyWithDeterminedDestination(NPath absoluteDestination, Func`2 fileFilter)
    �� System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
    �� System.Linq.Buffer`1..ctor(IEnumerable`1 source)
    �� System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
    �� Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet`1 objectFiles, CppToolChainContext toolChainContext)
    �� Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
    �� il2cpp.Program.DoRun(String[] args)
    �� il2cpp.Program.Run(String[] args)
    �� il2cpp.Program.Main(String[] args)

    回覆刪除
    回覆
    1. 我好像也遇到類似問題.. 只是我不太確定 改英文路徑是怎樣
      我的原本路徑上也都沒有中文阿

      刪除
    2. 不好意思,很久沒看Blogger,現在才看到🙈
      按照你的log來看,你應該是遭遇了某種IOException。這種Exception通常是在你【讀取/匯入/寫出/匯出檔案】時才會遇到。
      1. 最基本的猜測是:有沒有可能你匯入/匯出的檔案路徑有中文呢?(爆)
      2. 也有可能是缺乏對應名稱的檔案或路徑,導致讀取出錯。
      3. 我猜想,也有可能是讀取檔案的邏輯變更了。比方說,本來在Mac上編譯/撰寫的Unity專案,嘗試在Windows上進行輸出。那因為Mac跟Windows的檔案讀取路徑規則好像不太一樣,就可能造成錯誤。

      不論如何,歡迎你在這裡留言回報後續喔!也許也能幫到其他人了。

      刪除
  3. 我也遇到一樣的問題,謝謝

    回覆刪除
  4. 感謝,遇到一模一樣的問題,成功了

    回覆刪除