Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

srcCompact attribute not working using view style

I'm trying to use the attribute srcCompat in style:

<item name="app:srcCompat">@drawable/ic_work</item>

Android Studio says nothing about it but when compiling I get this error:

error: style attribute 'app:attr/srcCompat' not found. Message{kind=ERROR, text=error: style attribute 'app:attr/srcCompat' not found., sources=[D:...\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2888], original message=, tool name=Optional.of(AAPT)}

like image 638
Seraphim's Avatar asked Jun 14 '18 09:06

Seraphim's


2 Answers

Looks like you want to use the attribute within an style. Hence you don't need the app-prefix:

<item name="srcCompat">@drawable/ic_work</item>
like image 168
Christopher Avatar answered Sep 20 '22 13:09

Christopher


You need to add below code into gradle vectorDrawables.useSupportLibrary = true

android {  
    defaultConfig {  
        vectorDrawables.useSupportLibrary = true 
    }  
}
like image 29
Pankaj Kumar Avatar answered Sep 22 '22 13:09

Pankaj Kumar