Boron
Boron

Reputation: 129

Unknown attribute layout_width

I am working on android project, all was working well, until suddenly I opened Android Studio and found warnings all my layout files. E.g unknown attribute android:layout_width, unknown attribute android:id etc. I tried creating a new layout resource file and it also did the same, only options available now are constraint_width,height and so on. What could be my problem here?

enter image description here

Upvotes: 1

Views: 517

Answers (6)

Awesome Jim
Awesome Jim

Reputation: 378

Sometimes File -> Invalidate Caches/Restart. doesn't work, so do the manual clearing of the cache

1. Closed Android Studio.

2. Clear the contents of the C:\Users\MyUsername.AndroidStudio3.3\system\caches\ directory.

3. Relaunched Android Studio.

Upvotes: 0

Boron
Boron

Reputation: 129

None of the suggested solutions worked, I had to remove all my configuration settings, gradle files and uninstall AS, redownloading it was the only solution.

Upvotes: 0

Muhammad Nauman
Muhammad Nauman

Reputation: 169

I had similar issue but resolved by invalidating caches and restarting android studio: Go to Android Studio: File -> Invalide Caches/Restart.

Upvotes: 0

aanshu
aanshu

Reputation: 1602

Just go to Tools->Android->Sync Project with Gradle Files

Upvotes: 0

Mostafa Arian Nejad
Mostafa Arian Nejad

Reputation: 1655

In your android studio try steps below:

  1. File -> close project

  2. From the list click on the "X" button in front of your project to remove it from the recent projects (As marked in image).

enter image description here

  1. Click "open an existing Android Studio project", browse and select your project and reopen it.

  2. By step 3 problem should be solved, if it wasn't, click Build -> Rebuild project.

Upvotes: 0

Domin
Domin

Reputation: 1145

Just on menu bar invalide caches and restart Android-Studio: File -> Invalide Caches/Restart

That should help

Upvotes: 1

Related Questions