skip to Main Content

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.**

this is the error it shows

2

Answers


  1. 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 line app:srcCompat="@drawable/custom_image" to the ImageView tag, but it doesn’t remove the existing default avatar image reference. Removing android:src="@tools:sample/avatars" line from the ImageView tag helped me to get rid of this error.

    Login or Signup to reply.
  2. But when it’s occurs in the main activity. After Removed the default line the image got disappeared Here is what happened

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search