Benjamin Sadeghi
Benjamin Sadeghi

Reputation: 5

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

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>

Upvotes: 0

Views: 1407

Answers (2)

Arman Abdolmohammadi
Arman Abdolmohammadi

Reputation: 49

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.

Upvotes: 1

navylover
navylover

Reputation: 13539

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

Upvotes: 0

Related Questions