Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RelativeLayout "Couldn't resolve resource..." Android

Tags:

When using the below code, I get an error "Couldn't resolve resource @id/item1" Why is this? id/item1 is added before I use it, so I'm not sure why this is coming up.

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:orientation="vertical" >      <ImageView         android:id="@+id/item1"         android:layout_width="50dip"         android:layout_height="50dip"         android:src="@drawable/noimage" />     <TextView                  android:id="@+id/item2"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:text="Title"         android:padding="3dip"          android:textSize="20dip"         android:layout_toRightOf="@id/item1"/>     <TextView                  android:id="@+id/item3"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:text="Content"         android:padding="3dip"          android:textSize="20dip"         android:layout_below="@id/item1"/>  </RelativeLayout> 
like image 740
kieblera5 Avatar asked Dec 05 '11 19:12

kieblera5


2 Answers

I don't have this error with your code.

Make sure you don't have errors in other resources (layouts, values, drawables, etc.). And then clean/refresh/build the project

like image 85
inazaruk Avatar answered Oct 12 '22 23:10

inazaruk


As Jose said, sometimes Android Studio just gets crazy. But a restart ain't always enough.

Invalidate your caches and restart.

File -> Invalidate Caches / Restart... -> Invalidate and Restart

Menu Selection enter image description here

Wait until AS has completely restarted and rebuilt. Hopefully it'll behave logically.

like image 30
SMBiggs Avatar answered Oct 13 '22 00:10

SMBiggs