19

When I am adding android:id/background to the namespace, Lint complains that it "Cannot Resolve Symbol" even though I am requesting to add it rather than call it. The code works as written, but the error persists. When I change <item android:id="@+android:id/background" to <item android:id="@+id/background", the application stops working (another call breaks). My question is: why does Lint not recognize me adding android:id/background to the namespace even though a call to it functions well? Is there some better way to give this item an id that won't have Lint throw an error?

All three of the namespace definitions for the items in the layer-list below throw a lint error:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+android:id/background"
        android:drawable="@drawable/custom_ratingbar_empty" />
    <item android:id="@+android:id/secondaryProgress"
        android:drawable="@drawable/custom_ratingbar_empty" />
    <item android:id="@+android:id/progress"
        android:drawable="@drawable/custom_ratingbar_filled" />
</layer-list>

I found this and tried running build->clean as suggested with no success.

Community
  • 1
  • 1
Ethan Keller
  • 963
  • 3
  • 10
  • 26
  • What is `@+android:id` supposed achieve? `@+` is to add a previously undefined id. Are you trying to add an id in the predefined android namespace (that won't work)? – dhke Jul 27 '15 at 20:41

3 Answers3

41

If you are creating your own id:

"@+id/your_new_id"

if you are accessing your already created id

"@id/your_old_id"

if you are trying to access Android's system created id

"@android:id/system_id"

you can see the difference, if you are creating your own id then you have to add +. Since you are accessing system ID so you don't have to add +

Sharjeel
  • 15,588
  • 14
  • 58
  • 89
8

It seems you are using an extra +.

You should remove it, replace as follows @+android:id/background to @android:id/background.

tato.rodrigo
  • 2,783
  • 21
  • 26
  • Thanks, that works. I guess I just had to call that ID and it was already added to the namespace? Would you ever use @+android:id/background? Thanks for the help. – Ethan Keller Jul 27 '15 at 20:53
0

Try to replace @+android:id by @+id and see if it works!