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

Abhishek picture Abhishek · Feb 10, 2016 · Viewed 26k times · Source
  • 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 is a Snap shot

enter image description here

enter image description 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.

In App Level Gridle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.example.abhishek.ondemandservice"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),     'proguard-rules.pro'
        }
    }
}

Application level Gride.

buildscript {
    repositories {
        maven { url "http://dl.bintray.com/populov/maven" }
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven { url "http://dl.bintray.com/populov/maven" }
        jcenter()
        mavenCentral()
    }
}

Answer

Marius Gheorghe picture Marius Gheorghe · Dec 14, 2017

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