Unity – Failed to re-package resources.

追查到後來, 其實這個主題很廣泛, 但很多人應該會用這關鍵字搜尋, 方便各位找到這篇~

環境:
win 10
build-tools:23.0.3
unity 5.2.5f1
這次問題蠻明確的, 環境沒有太大差別.

這是發生在我們專案從 Unity 升級版本後, 因為某些狀況需要降回版本(5.3 -> 5.2).
但這中間的一些修正理論上都可以共用, 所以就沒特別 revert 資源包以外的項目.

BUT!!!

這世界上最讓人崩潰的也就是這個 BUT!!

Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
C:\Users\nacl\AppData\Local\Android\sdk\build-tools\23.0.3\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "C:/Users/nacl/AppData/Local/Android/sdk\platforms\android-24\android.jar" -F bin/resources.ap_

stderr[
AndroidManifest.xml:4: error: Error: No resource found that matches the given name (at 'theme' with value '@style/UnityThemeSelector').

]
stdout[
Configurations:
 (default)
 xhdpi-v4

Files:
  drawable\app_banner.png
    Src: (xhdpi-v4) res\drawable-xhdpi\app_banner.png
  drawable\app_icon.png
    Src: () res\drawable\app_icon.png
  values\strings.xml
    Src: () res\values\strings.xml
  AndroidManifest.xml
    Src: () AndroidManifest.xml

Resource Dirs:
  Type drawable
    drawable\app_banner.png
      Src: (xhdpi-v4) res\drawable-xhdpi\app_banner.png
    drawable\app_icon.png
      Src: () res\drawable\app_icon.png
  Type values
    values\strings.xml
      Src: () res\values\strings.xml
Including resources from package: C:\Users\nacl\AppData\Local\Android\sdk\platforms\android-24\android.jar
applyFileOverlay for drawable
applyFileOverlay for layout
applyFileOverlay for anim
applyFileOverlay for animator
applyFileOverlay for interpolator
applyFileOverlay for transition
applyFileOverlay for xml
applyFileOverlay for raw
applyFileOverlay for color
applyFileOverlay for menu
applyFileOverlay for mipmap
Processing image: res\drawable-xhdpi\app_banner.png
Processing image: res\drawable\app_icon.png
    (processed image res\drawable\app_icon.png: 94% size of source)
    (processed image res\drawable-xhdpi\app_banner.png: 93% size of source)
    (new resource id app_banner from xhdpi-v4\drawable\app_banner.png #generated)
    (new resource id app_icon from drawable\app_icon.png #generated)
]

準備包 apk 的時候獲得一長串的訊息…||||Orz
經過幾次交叉比對終於找到問題點, 也順便學習到該怎麼面對這類的錯誤訊息 (苦笑

其中最需要關注的是 stderr 裡面的內容!!
在一般專案中, 可能會有混砸很多其他訊息, 像是我們專案就有一堆 plugin 的 note…
結果就沒看到被淹沒的重要訊息, 因此白白浪費了不少時間在找問題點QQ

stderr[
AndroidManifest.xml:4: error: Error: No resource found that matches the given name (at 'theme' with value '@style/UnityThemeSelector').
]

我們的狀況, 其實就只是找不到指定的 android theme 而已…
設定一個可用的即可~

ref:
用Unity和Android交互出现一个问题,请大家看看」也是找不到對應 theme
Failed to re-package resources.」是找不到對應的 value

題外話, 如果有遇到 android 設備上的輸入框內文文字看不清/看不見(前景色&被景色相同), 像是這串的討論.
主因是 android theme 設定的問題.

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s