I have a shape in one of my xml drawables that uses the styles of my themes.xml file:
<shape android:shape="oval">
<gradient
android:gradientRadius="134dp"
android:startColor="?colorPrimary"
android:centerColor="#000000"
android:endColor="#000111"
android:type="radial" />
</shape>
As you can see startColor uses the colorPrimary attribute. However, when I launch the app in the Android Studio emulator it crashes without build error. When I replace ?colorPrimary by a random hex color everything seems to be fine. I’m using API 24 and as far as I know you can use ?colorVariant for >API 21. Not sure what I’m doing wrong here.
Source: Android Questions