Unknown attribute android:layout_width, layout_height, id, gravity, layout_gravity, padding

蹲街弑〆低调 提交于 2019-11-28 06:08:12

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

Mohamed Akl

The only thing that worked for me was cleaning the following folders:

c:\Users\<user>\.gradle\caches\
c:\Users\<user>\.AndroidStudio3.2\system\caches\

Android Studio will just redownload the libraries and caches them which will enable everything back to normal.

Source: https://stackoverflow.com/a/53053438/7515903

Credits: @alexuz

To fix, change something in your gradle file, then sync gradle again. This worked for me.

Credit: https://stackoverflow.com/a/47500156/5673746

I tried:

  • Removing the build folders
  • Cleaning the project
  • Sync Project with Gradle Files

But nothing worked. Finally using File > Invalidate caches fixed the error.

I too encountered this..

  1. Just delete the .idea folder that is in the project location

  2. Build > Clean Project

  3. Then change something in the app level gradle

Then android studio will ask you to sync the project. Go ahead and sync, the problem will be gone

Had the same issue, but after a reinstall of visual studio, so what helped for me on Android studio 3.2, was to go and upgrade the target version to 28 and compile version 28. Was at version 27 before.

I had to upgrade these packages as well

implementation "com.android.support:support-v4:28.0.0"
implementation 'com.android.support:support-core-ui:28.0.0'

After Gradle had synced then it worked for me.

Mohammad Hadi

if non of above answers dosn't work do these steps:

  1. first close android studio.
  2. than just go to windows>User or AppData>local> and delete androidstudio last version folder
  3. reopen androidstuduio and set default settings

In my case none of the above solutions worked for me, but changing the minSdkVersion to a higher version and doing a gradle sync after that did the trick, maybe this would be useful to somebody.

Any of these ways will possibly fix your problem (unknown attribute android:layout-width)

  1. Sync project with Gradle file (File -> Sync project with Gradle files)
  2. Invalidate cache and restart (File -> Invalidate cache and restart -> Invalidate and restart)
  3. Delete .gradle and .idea file from the project folder and rebuild the project.
  4. Delete caches folder from Android studio (.AndroidStudio3.2 -> system -> caches)
Hulu

None of the existing suggestion works for me. I solved this issue by reinstalling Android Studio. Really weird.

I had to

  1. Delete Android SDK from AppData\Local\Android\Sdk
  2. Reinstall Android Studio

I just changed my android SDK path and restart android studio->set new SDK path it working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!