Reputation: 2370
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
Things i have done to resolve this issue.
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()
}
}
Upvotes: 90
Views: 37343
Reputation: 739
If you're facing this issue only for a few of the attributes like android:text or android:layout_margin, etc, check if your compileSdkVersion is 33 in gradle, and try downgrading it to 32 in build.gradle(:app)
Upvotes: 2
Reputation: 49
I´ve tryed all the solutions but the only thing that worked for me was 4gus71n's answer.
Deleting the C:\Users.AndroidStudio3.2\system\caches folder solved my problem.
Link to his answer: https://stackoverflow.com/a/53160674/6568421
Upvotes: 1
Reputation: 199
I changed the compileSdkVersion
/buildToolsVersion
/targetSdkVersion
from 30 to 29 in build.gradle
and the problem disappeared for me.
Upvotes: 1
Reputation: 652
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
Upvotes: 51
Reputation: 152
Any of these ways will possibly fix your problem (unknown attribute android:layout-width)
Upvotes: 6
Reputation: 1986
if non of above answers dosn't work do these steps:
Upvotes: 3
Reputation: 444
I just changed my android SDK path and restart android studio->set new SDK path it working
Upvotes: 0
Reputation: 191
I had to
Upvotes: 1
Reputation: 1633
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.
Upvotes: 6
Reputation: 11
None of the existing suggestion works for me. I solved this issue by reinstalling Android Studio. Really weird.
Upvotes: 1
Reputation: 101
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.
Upvotes: 2
Reputation: 36007
I tried:
But nothing worked. Finally using File > Invalidate caches fixed the error.
Upvotes: 11
Reputation: 1210
I too encountered this..
Just delete the .idea folder that is in the project location
Build > Clean Project
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
Upvotes: 5
Reputation: 1839
To fix, change something in your gradle file, then sync gradle again. This worked for me.
Credit: https://stackoverflow.com/a/47500156/5673746
Upvotes: 16