[英]FAILURE: Build failed with an exception - Android
我正在嘗試升級我的舊 Android 項目並遇到以下錯誤:
> Task :app:mergeDebugResources FAILED
/home/jaiminmodi/.gradle/caches/transforms-3/08e5f3aa7ebe2a199cff2b386779108c/transformed/core-1.7.0/res/values/values.xml:162:4: Duplicate value for resource 'attr/font' with config 'DEFAULT' and product ''. Resource was previously defined here: com.brian.skyazul.activity.app-mergeDebugResources-16:/values/values.xml:2739: .
> Task :app:mergeLibDexDebug UP-TO-DATE
> Task :app:mergeDebugJniLibFolders UP-TO-DATE
> Task :app:mergeDebugNativeLibs NO-SOURCE
> Task :app:stripDebugDebugSymbols NO-SOURCE
> Task :app:validateSigningDebug UP-TO-DATE
> Task :app:writeDebugAppMetadata UP-TO-DATE
> Task :app:writeDebugSigningConfigVersions UP-TO-DATE
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.ResourceCompilerRunnable
> Resource compilation failed (Failed to compile values resource file /home/jaiminmodi/StudioProjects/skyazul-android/app/build/intermediates/incremental/debug/mergeDebugResources/merged.dir/values/values.xml. Cause: java.lang.IllegalStateException: Can not add resource (com.android.aaptcompiler.ParsedResource@66c6c035) to table.). Check logs for more details.
* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:mergeDebugResources'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:145)
at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:143)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:131)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:77)
at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
可能是什么問題?
由於它是較舊的 android 項目,attr.xml 文件的 xml 代碼如下所示:
<resources>
<declare-styleable name="CustomFont">
<attr name="font" format="string" />
</declare-styleable>
根據錯誤,我們可以使用font關鍵字作為name參數的值。 所以解決方案是更改為其他一些值,例如fontName
所以,我在更改更新后的文件如下所示:
<resources>
<declare-styleable name="CustomFont">
<attr name="fontName" format="string" />
</declare-styleable>
</resources>
並在此字體用於fontName的位置進行了更改
就這樣。
答案如下。
/home/jaiminmodi/.gradle/caches/transforms-3/08e5f3aa7ebe2a199cff2b386779108c/transformed/core-1.7.0/res/values/values.xml:162:4: Duplicate value for resource 'attr/font' with config 'DEFAULT' and product ''. Resource was previously defined here: com.brian.skyazul.activity.app-mergeDebugResources-16:/values/values.xml:2739: .
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.