4

After upgrade to androidx and SDK 28 I get the following error when building my project:

.../app/src/main/res/values/styles.xml:90:5-93:13: AAPT: error: expected reference but got (raw string) #000000.

The relevant lines of values/styles.xml:

<style name="menu_labels_style">
    <item name="android:background">@drawable/fab_label_background</item>
    <item name="android:textColor">@color/white</item>
</style>

The fab_label_background resource (just in case) is:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="@color/black_semi_transparent"/>
    <padding
        android:left="16dp"
        android:top="4dp"
        android:right="16dp"
        android:bottom="4dp"/>
    <corners
        android:radius="2dp"/>
</shape>
Ryan M
  • 18,333
  • 31
  • 67
  • 74
olegstepanov
  • 157
  • 2
  • 7
  • #000000 find for this in your style.xml and then create an entry for this color in color.xml and then use its string reference. – MindRoasterMir Aug 26 '22 at 21:45

3 Answers3

0

Imagine my surprise that googling a problem I was having brought me back to this question I'd totally forgotten about, but there's my own name in the comments.

However this time, I may actually have an answer:

In your build.gradle file, look for:

implementation 'com.google.android.material:material:1.0.0-rc01'

and change to a newer version.

implementation 'com.google.android.material:material:1.4.0'

But don't use 1.5.0-alpha03 (the latest as of this writing), it has problems too.

Edward Falk
  • 9,991
  • 11
  • 77
  • 112
0

#000000 find for this in your style.xml

<item name="background">#000000</item>

then create an entry for this color in color.xml and then use its string reference.

<color name="black">#000000</color>

<item name="background">@color/black</item>

it wont give this error anymore.

MindRoasterMir
  • 324
  • 1
  • 2
  • 18
0

I just used the "Migrate to AppCompat" feature of Android Studio.

It changed the line <item name="android:background">...</item>

in my styles.xml file to <item name="background">...</item>,

and I started getting an error. When I reverted the change, the error went away.

OzgurG
  • 1,634
  • 1
  • 16
  • 21