Moisoni Ioan
Moisoni Ioan

Reputation: 1425

Unknown attribute warning in XML

AndroidManifest and XML layouts are showing me the Unknown attribute android: warning even though the attributes exist and the app works on the device.

Example: Unknown attribute android:maxSdkVersion, android:clickable="true" etc.

I am aware of the other questions regarding this issue and tried everything I could find about this topic but nothing works for me. I tried to:

Sync Project with Gradle Files

Delete the .idea and .gradle folders from the project location

Delete caches from c:\Users\<user>\.gradle\caches\

Invalidate caches and restart ...and many other things I couldn't remember right now.

The problem still persists on a newly installed OS (Windows 11) and obviously, newly installed Android Studio, and also the issue affects only old projects...

Also, my project is up to date with everything the Android Studio doesn't show me any warning to update a version of a dependency or so.

Gradle version 7.3.3 Android Gradle Plugin Version 7.2.1

Update:

The warning appears only with the SDK version 33 (compileSdkVersion 33), if I build with version 32, the warning disappears...

Update2:

New projects which use API level 33 still show the warning... Maybe it's a bug in the SDK?

Upvotes: 52

Views: 14769

Answers (5)

danyapd
danyapd

Reputation: 2506

UPD 20.01.2023: You can update Android Studio to the latest version now (Android Studio Electric Eel | 2022.1.1) and this bug is fixed there. Worked for me.


OLD: Got same crap and a lot of other. And yes, just downgraded buildToolsVersion to "32.1.0 rc1" and targetSdkVersion, compileSdkVersion to API 32 for as long as bug exists in API 33.

Upvotes: 30

Cor
Cor

Reputation: 439

This config works for me:

Android Studio Dolphin | 2021.3.1
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

compileSdk 33 (SDK 33 Rev. 2, Sources 33 Rev. 1) 
buildToolsVersion "33.0.0"
targetSdkVersion 33

Gradle Plugin version 7.3.0.

Upvotes: 0

harry
harry

Reputation: 261

Perfect!! set compileSdkVersion to 32

 compileSdkVersion 32

set targetSdkVersion to 32

  targetSdkVersion 32

downgrade androidx.core:core-ktx

 implementation 'androidx.core:core-ktx:1.8.0'

Upvotes: 7

Kieron
Kieron

Reputation: 2028

It's not ideal, but switching to Dolphin RC1 resolves this. Given that it will (presumably) hit stable pretty soon, it may not get fixed in Chipmunk. You can download Dolphin from the Android Studio Preview page, just be aware that it is not available as an installer so you will need to manually update your installed version or use it alongside until it hits stable.

Upvotes: 8

Akexorcist
Akexorcist

Reputation: 2297

Same here, I use this temporary workaround until Android team fix this issue or better solution.

  • Move all require code for Android 13 into library module (in my case, all of them are moved into utility module) and keep it use compile SDK 33
  • Temporary changes compile SDK in other module to 32 for local development

Upvotes: 8

Related Questions