Unknown attribute android:layout_width, layout_height, id, gravity, layout_gravity and other attribute in xml

1.2k views Asked by At
  • Getting Unknown attribute error on all android tag.
  • In layout XML, Auto suggestion is not showing all attributes (like layout_width, layout_height, orientation, orientation & all others android attributes.)

here Things i have done to resolve this issue:

  • Clean Build & Rebuild
  • Deleted .idea
  • file Invalidated Caches/Restart..
  • option Turn On Power Save Mode.

SDk is up to date.

my xml layout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    tools:context=".MainActivity"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_height="match_parent"
    android:layout_width="match_parent">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>
2

There are 2 answers

4
Arman Abdolmohammadi On BEST ANSWER

I had same problem just like you and I did all of things that you've done and here is my solution. maybe problem is your targetSDKversion in gradle. if it is 28.0.0 you can change it to 27.1.1 and sync your project with gradle files.

this can help you to solve it.

0
navylover On

Change something in your app module build.gradle file, for example, comment a line, then click File and then Sync Project with Gradle Files.