プロジェクトをビルドできません。 attr/colorSecondary not foundエラーが表示されます。
私のスタイルとマニフェストを見て、何が悪いのか教えてください。
Android Studioバージョン:3.0 Canary 9
compileSdkVersion 25
buildToolsVersion '25 .0.3 '
minSdkVersion 17
スタイル
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/primaryColor</item>
<item name="colorSecondary">@color/secondaryColor</item>
</style>
色
<color name="primaryColor">#fcc425</color>
<color name="secondaryColor">#e5af17</color>
マニフェスト
<application
Android:allowBackup="true"
Android:icon="@drawable/ic_launcher"
Android:label="@string/app_name"
Android:theme="@style/AppTheme">
依存関係
compile 'com.Android.support:appcompat-v7:25.3.1'
エラーメッセージ
C:\ Users\Raja.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.3.1.aar\9d599a32a67c8fb41b4e2d36c5f93152\res\values\values.xml
エラー:(353、5)スタイル属性 'attr/colorSecondary(aka com.equitasbank.merchant:attr/colorSecondary)'が見つかりません
エラー:D:\ Android Projects\Purz Merchant\Equitas Merchant Android\app\build\intermediates\incremental\mergeLiveDebugResources\merged.dir\values\values.xml:609スタイル属性 'attr/colorSecondary(aka com.equitasbank.merchant: attr/colorSecondary) 'が見つかりません
エラー:Java.util.concurrent.ExecutionException:com.Android.builder.internal.aapt.AaptException:AAPT2 link failed:
エラー:com.Android.builder.internal.aapt.AaptException:AAPT2 link failed:
エラー:タスク ':app:processLiveDebugResources'の実行に失敗しました。 aaptの実行に失敗しました
コンソールエラー
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)
助けてください。前もって感謝します:)
AS 3.0のアイテムで「attr」タイプを明示的に定義する必要があります
例えば。
<item type="attr" name="colorPrimary">@color/primaryColor</item>
また、attrs.xmlで属性を定義することを忘れないでください。例えば。
<declare-styleable name="Theme">
<attr name="colorPrimary" format="color|reference" />
</declare-styleable>
表示されるエラーは、問題のテーマがTheme.AppCompat.Light.NoActionBar
には属性secondaryColor
が含まれていません。したがって、基本的にしようとしているのは、存在しない属性に値を割り当てることです。
必要に応じて、既存の属性から選択できます(属性を取得する最も簡単な方法は、item name = ""
)、または通常の色を追加してレイアウトで直接使用するか、Javaコード。