[英]FAILURE: Build failed with an exception - Android
I am trying to upgrade my old Android project and getting below errors :我正在尝试升级我的旧 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)
What might be the issue?可能是什么问题?
Since it was older android project, the xml code of attr.xml file was look like as below :由于它是较旧的 android 项目,attr.xml 文件的 xml 代码如下所示:
<resources>
<declare-styleable name="CustomFont">
<attr name="font" format="string" />
</declare-styleable>
and as per the error, we can use font keyword for the value of name parameter.根据错误,我们可以使用font关键字作为name参数的值。 So the Solution is to change to some other value such as fontName
所以解决方案是更改为其他一些值,例如fontName
So, I After change the updated file looks like as below :所以,我在更改更新后的文件如下所示:
<resources>
<declare-styleable name="CustomFont">
<attr name="fontName" format="string" />
</declare-styleable>
</resources>
and done changes where this font was used to fontName并在此字体用于fontName的位置进行了更改
That's All.就这样。
答案如下。
/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.