2
I am new to Android dev and am working on my first app. I have been running into trouble trying to get an image view set up with my own image (stock photos on studio are working fine), and am getting the following error:
AAPT: error: ‘@tools:sample/avatars’ is incompatible with attribute src (attr) reference|color.
What this error means.
How to troubleshoot this.
Where my mistake lies.**
2
Answers
In the latest Android Studio, there is a default avatar image added when you drag and drop an ImageView to the Component Tree, and it’ll add the line
android:src="@tools:sample/avatars"
to the ImageView tag by default. If you are replacing the default image with your custom_image Android Studio will automatically add another lineapp:srcCompat="@drawable/custom_image"
to the ImageView tag, but it doesn’t remove the existing default avatar image reference. Removingandroid:src="@tools:sample/avatars"
line from the ImageView tag helped me to get rid of this error.But when it’s occurs in the main activity. After Removed the default line the image got disappeared Here is what happened