Home > OS >  FAILURE: Build failed with an exception - Android
FAILURE: Build failed with an exception - Android

Time:07-21

I am trying to upgrade my old Android project and getting below errors :

> 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?

CodePudding user response:

Since it was older android project, the xml code of attr.xml file was look like as below :

<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. So the Solution is to change to some other value such as 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

That's All.

CodePudding user response:

Answer is below.

/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: .
  • Related