0

I've been using Android Studio perfectly well for a long time now but when I tried using CardView in my layout file.

Information:Gradle tasks [:app:assembleDebug]
/Users/professori/.gradle/caches/transforms-1/files-1.1/cardview-v7-25.0.0.aar/1cf3ea204bf2d379f4a71d608f48a715/res/values/values.xml
Error:(18, 5) error: expected color reference but got (raw string) #000t.
/Users/professori/Projects/house/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml
Error:(2146) expected color reference but got (raw string) #000t.
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 19s
Information:7 errors
Information:0 warnings
Information:See complete output in console

I am using buildToolsVersion 27.0.1 and v26.1.0 of the respective support libraries. My gradle version is 3.0.1.

I have tried cleaning the project multiple times and even restarting Android Studio but it hasn't helped. Some StackOverflow answers suggest disabling aapt2 in gradle.properties but that just brings some more problems I'd rather not get into.

Is there a permanent way of getting rid of this problem? It's now happened twice in 2 separate projects I'm working on.

Alex Kombo
  • 3,256
  • 8
  • 34
  • 67
  • 1
    It looks like this library is trying to use "#000t" as a color, but it's not a valid code. You can look at the XML file (/Users/professori/.gradle/caches/transforms-1/files-1.1/cardview-v7-25.0.0.aar/1cf3ea204bf2d379f4a71d608f48a715/res/values/values.xml), find which resource is using the incorrect color and override it in your own app to fix this error. – Izabela Orlowska Jan 05 '18 at 16:20
  • any update about which resource was using the invalid color? – Izabela Orlowska Jan 23 '18 at 14:26

1 Answers1

0

I think there is a problem with the color code You are using "#000t" use a correct color code after rebuild it, this will work if not then try below solutions

1:- remove all unnecessary XML files from your code

2:- Reopen and Check XML files

clean and Rebuild Project

If there is Still Problem

Go to your gradle.properties write the below code

android.enableAapt2=false 

and then Go to your build.gradle(app) write the below code and Sync your project

aaptOptions {
        cruncherEnabled = false
    }

Like this Image

Note android.enableAapt2=false is deprecated, and will be removed by the end of 2018, so this doesn't solve the problem, is just a temporary workaround