天天看點

A failure occurred while executing com.android.build.gradle.tasks.MergeResources$FileGenerationWorkA

從GitHub上下載下傳一個項目,導入Android studio之後報錯。報錯内容如下:

Error:There were multiple failures while executing work items

Error:Execution failed for task ':app:mergeDebugResources'.

> There were multiple failures while executing work items

   > A failure occurred while executing com.android.build.gradle.tasks.MergeResources$FileGenerationWorkAction

      > Error while processing D:\androidProject\KuaiChuan-master\app\src\main\res\drawable\ic_storage_24dp.xml : Can't process attribute android:fillColor="@color/color_storage": references to other resources are not supported by build-time PNG generation. See http://developer.android.com/tools/help/vector-asset-studio.html for details.

   > A failure occurred while executing com.android.build.gradle.tasks.MergeResources$FileGenerationWorkAction

      > Error while processing D:\androidProject\KuaiChuan-master\app\src\main\res\drawable\ic_device_24dp.xml : Can't process attribute android:fillColor="@color/color_device": references to other resources are not supported by build-time PNG generation. See http://developer.android.com/tools/help/vector-asset-studio.html for details.

   > A failure occurred while executing com.android.build.gradle.tasks.MergeResources$FileGenerationWorkAction

報錯的截圖如下:

A failure occurred while executing com.android.build.gradle.tasks.MergeResources$FileGenerationWorkA

這個bug解決起來也比較簡單,在你的app的build.gradle的defaultConfig中添加如下的代碼就可以了:

defaultConfig{  
   vectorDrawables.useSupportLibrary = true  
}  
           

添加完 vectorDrawables.useSupportLibrary = true這行代碼之後,gradle一下就可以了。

A failure occurred while executing com.android.build.gradle.tasks.MergeResources$FileGenerationWorkA

如果本文對您有所幫助,麻煩點選一下左側的點贊按鈕,謝謝。