web-dev-qa-db-fra.com

Attribut de style attr / color Secondaire introuvable

Je ne peux pas construire mon projet. Il me montre une erreur attr/colorSecondary not found.

Regardez mes styles et mon manifeste et dites-moi ce qui ne va pas.

Version studio Android: 3.0 canary 9

compileSdkVersion 25

buildToolsVersion '25 .0.3 '

minSdkVersion 17

Style

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/primaryColor</item>
    <item name="colorSecondary">@color/secondaryColor</item>
</style>

Couleurs

 <color name="primaryColor">#fcc425</color>
 <color name="secondaryColor">#e5af17</color>

Manifest

<application
        Android:allowBackup="true"
        Android:icon="@drawable/ic_launcher"
        Android:label="@string/app_name"
        Android:theme="@style/AppTheme">

Dépendance

compile 'com.Android.support:appcompat-v7:25.3.1'

Message d'erreur

C:\Users\Raja.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\9d599a32a67c8fb41b4e2d36c5f93152\res\values ​​\ values.xml

Erreur: (353, 5) attribut de style "attr/colorSecondary (alias com.equitasbank.merchant: attr/colorSecondary)" introuvable

Erreur: D:\Android Projects\Purz Merchant\Equitas Merchant Android\app\build\intermediates\incremental\mergeLiveDebugResources\merged.dir\values ​​\ values.xml: attribut de style 609 'attr/colorSecondary (alias com.equitasbank.merchant: attr/colorSecondary) 'introuvable

Erreur: Java.util.concurrent.ExecutionException: com.Android.builder.internal.aapt.AaptException: la liaison AAPT2 a échoué:

Erreur: com.Android.builder.internal.aapt.AaptException: échec de la liaison AAPT2:

Erreur: l'exécution a échoué pour la tâche ': app: processLiveDebugResources'. Impossible d'exécuter aapt

Erreur de console

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processLiveDebugResources'.
> Failed to execute aapt

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processLiveDebugResources'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.Java:100)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.Java:70)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.Java:63)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.Java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.Java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.Java:88)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.Java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.Java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.Java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.Java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.Java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.Java:248)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.Java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.Java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.Java:197)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.Java:107)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.Java:241)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.Java:230)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.Java:124)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.Java:80)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.Java:105)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.Java:99)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.Java:625)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.Java:580)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.Java:99)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.Java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.Java:46)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.Java:55)
Caused by: org.gradle.tooling.BuildException: Failed to execute aapt
    at com.Android.build.gradle.tasks.ProcessAndroidResources.invokeAaptForSplit(ProcessAndroidResources.Java:583)
    at com.Android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.Java:281)
    at com.Android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.Java:106)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.Java:73)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.Java:173)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.Java:134)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.Java:121)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.Java:122)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.Java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.Java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.Java:197)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.Java:107)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.Java:111)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.Java:92)

Veuillez aider. Merci d'avance:)

11
Raja

Vous devez définir explicitement le type "attr" dans l'élément dans AS 3.0

par exemple.

<item type="attr" name="colorPrimary">@color/primaryColor</item>

Documents: https://web.archive.org/web/20180518223123/https://developer.Android.com/studio/build/gradle-plugin-3-0-0-migration

N'oubliez pas non plus de définir l'attribut dans votre attrs.xml. par exemple.

<declare-styleable name="Theme">
    <attr name="colorPrimary" format="color|reference" />
</declare-styleable>
14
Jeremy

L'erreur que vous obtenez indique que le problème est que le thème nommé Theme.AppCompat.Light.NoActionBar ne contient pas d'attribut secondaryColor. Donc, ce que vous essayez essentiellement de faire est d'attribuer une valeur à un attribut inexistant.

Selon vos besoins, vous pouvez choisir parmi les attributs existants (le moyen le plus simple de les obtenir consiste à appuyer sur CTR + ESPACE entre guillemets vides dans item name = ""), ou ajoutez simplement de la couleur normale et utilisez-la directement dans la mise en page ou Java code.

3
Gotiasits