error: failed linking references. -> QueuedJob

2019-06-16 20:01发布

问题:

I was studying the Android Material Design using Kotlin and everything was going fine until I tried to use the android.support.design.widget.FloatingActionButton.

When I rebuild the project I got the error message below:

Information:Gradle tasks [clean, :app:assembleDebug]
C:\Users\qin\.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.1.0.aar\3d5ddc383685b19d22429a29e09f2aeb\res\values\values.xml
Error:(1419, 5) error: style attribute 'attr/textColor (aka br.com.conseng.themedesign:attr/textColor)' not found.
Error:(1525, 5) error: style attribute 'attr/textColor (aka br.com.conseng.themedesign:attr/textColor)' not found.
.....\CursoMaterialDesign\ThemeDesign\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Error:(1843) style attribute 'attr/textColor (aka br.com.conseng.themedesign:attr/textColor)' not found.
Error:(1953) style attribute 'attr/textColor (aka br.com.conseng.themedesign:attr/textColor)' not found.
Error:failed linking references.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt
Information:BUILD FAILED in 15s
Information:9 errors
Information:0 warnings
Information:See complete output in console

I saved the source files on GitHub and my environment is:

  • WINDOWS 10 10.03.0.1 (64-bit)
  • ANDROID STUDIO Android Studio 3.0.1 - Build #AI-171.4443003
  • JRE: 1.8.0_152-release-915-b01 amd64
  • JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

I tried:

  1. The FILE->INVALIDATE CACHE/RESTART command, but nothing changed.
  2. I executed the gradlew cleanBuildCache on the terminal, but it could not determine java version from '9.0.1' (?) as shown below.
gradlew cleanBuildCache --stacktrace --debug
14:05:14.966 [INFO] [org.gradle.internal.nativeintegration.services.NativeServices] Initialized native services in: C:\Users\qin\.gradle\native
14:05:15.038 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:05:15.039 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
14:05:15.039 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:05:15.039 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
14:05:15.042 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Could not determine java version from '9.0.1'.
14:05:15.042 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:05:15.042 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
14:05:15.043 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] java.lang.IllegalArgumentException: Could not determine java version from '9.0.1'.
14:05:15.043 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.JavaVersion.toVersion(JavaVersion.java:72)
14:05:15.043 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.JavaVersion.current(JavaVersion.java:82)
14:05:15.043 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.jvm.UnsupportedJavaRuntimeException.assertUsingVersion(UnsupportedJavaRuntimeEx
ception.java:29)
14:05:15.044 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:32)
14:05:15.044 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
14:05:15.044 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
14:05:15.044 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
14:05:15.044 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:
253)
14:05:15.044 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:
182)
14:05:15.044 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.Main.doAction(Main.java:33)
14:05:15.044 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
14:05:15.044 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
14:05:15.044 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
14:05:15.045 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:43)
14:05:15.045 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at java.base/java.lang.reflect.Method.invoke(Method.java:564)
14:05:15.045 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
14:05:15.045 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
14:05:15.045 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
14:05:15.045 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
14:05:15.045 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
14:05:15.045 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:43)
14:05:15.046 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at java.base/java.lang.reflect.Method.invoke(Method.java:564)
14:05:15.046 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
14:05:15.046 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
14:05:15.046 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
14:05:15.046 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:05:15.046 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:05:15.046 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org

回答1:

You were referencing an attribute "textColor", when it should be "android:textColor".
In app/src/main/res/values/styles.xml replace in line 13 and line 17:

<item name="textColor">...</item> -> <item name="android:textColor">...</item>

The how: the error from AAPT stated the following:

error: style attribute 'attr/textColor (aka br.com.conseng.themedesign:attr/textColor)' not found.

It points out that you (or your libraries) are using an attribute somewhere that is not recognized. I searched for "textColor" in your repository and came up with the two attributes with the name "textColor". The widely used attribute is "android:textColor" and you didn't define the attribute "textColor" anywhere yourself, so it looked like you were missing the "android:" prefix.



回答2:

I've just deleted my color resourse, but it have been used in my style. So, check if your colors are really not using anywhere by Ctrl+Shift+F.



回答3:

Remove this line from dependencies in gradle build file:

implementation 'com.android.support.constraint:constraint-layout:+'


回答4:

For my situation, my compileSdkVersion < targetSdkVersion in build.gradle. Just change compileSdkVersion >= targetSdkVersion.