27

After I update the target Android SDK from 30.0.3 to 31.0.0 I started to have these 2 warnings :

This version only understands SDK XML versions up to 2 but an SDK XML file of version 3 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.

Warning: unexpected element (uri:"", local:"base-extension"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>

I tried to update all the libraries but it didn't help. Anyone had this warning ?

Edgar Khimich
  • 948
  • 1
  • 11
  • 15
  • 2
    I also have the exact same issue since changing to 31.0.0 – DanMossa Dec 05 '21 at 22:18
  • You might get that if mixing up or upgrading components. I could remove the 'SDK XML' message by doing a 'Clean Project' after messing with Studio versions. The 'unexpected element' issue is bothering me for a while. Seems it has to do with the inner 'repository' XML files. The 'sdk-repository' element shows on line 304 an example. I assume the warning can be ignored. See https://github.com/eagletmt/android-repository-history/blob/master/repository/repository2-1.xml#L304 – Michael Jan 17 '22 at 16:28

4 Answers4

2

This is caused by using a newer version of commandline-tools to download the packages of Android SDK, while your project is probably using an older version of Gradle.

Enter your Android SDK directory and delete everything but the licenses folder. Try to rebuild your project and Gradle will redownload all the tools needed. This time the warning won't be logged.

Petrakeas
  • 1,303
  • 12
  • 24
1

Answer from an "official" source:

As mentioned in the message, this is happening because you have some packages that were installed that are using the v3 format for package.xml, but then reading it with a tool that only knows about v2. Probably you installed some components using the canary studio. If you want to you could uninstall the problem components and reinstall using sdkmanager or the stable studio. Or you could just ignore the message for now, until the new cmdline-tools is out, which should happen alongside the next studio stable release. -- https://issuetracker.google.com/issues/207386175#comment3

TWiStErRob
  • 41,170
  • 22
  • 156
  • 240
0

It come from an update of Gradle after installation of Android SDK PLateforms & an application's build.

This require reinstallation of SDK Plateforms & delete/rebuild of application.

To remove the warning :

  • Uninstall SDK Plateforms>Android SDK Platform XX
  • Delete all files built by the application (build folder, gradle files, …)
  • re-Install SDK Plateforms>Android SDK Platform XX
  • Build application

Source : https://titanium.dzzd.net/t/gradle-warning-message-during-building/36/8?u=dzzd

DzzD
  • 11
  • 2
-5

I'm also getting this message trying to use sdkmanager and avdmanager (no Android Studio installed).

Dom Barnes
  • 74
  • 1
  • 2