I am getting the following error when I am building my project . How do I correct this ?

C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(3,3): Error: java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0 (FGH)


My version information from Help > About > Show Details:

Xamarin.Android Version: 6.0.2.1 (Starter Edition)
Android SDK: C:\Users\Admin\AppData\Local\Android\android-sdk

Supported Android versions:

  • 4.0.3 (API level 15)
  • 4.4 (API level 19)
  • 6.0 (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.0.1
SDK Build Tools Version: 24 rc2

Java SDK: C:\Program Files (x86)\Java\jdk1.7.0_71
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14) Java HotSpot(TM) Client VM (build 24.71-b01, mixed mode, sharing)

10 Answers 11

up vote 50 down vote accepted

The version 52.0 here is referring to the specific release of the JDK, which in this case relates to JDK 8.

Xamarin.Android 7.0 requires JDK 1.8 to use the Android Nougat (API 24) APIs. You can continue to use earlier versions of the JDK if targeting earlier Android API levels:

Additionally, a 64-bit version of the JDK is required to use custom controls in the Android designer.

The simplest option is to install the 64-bit version of JDK 1.8 since it is backwards compatible with all of the previous API levels and supports the new Android designer features.

(One unfortunate complication with JDK 1.8 is that is not compatible with the outdated version of Proguard that is included in the Android SDK. Currently this will cause an error "Unsupported class version number [52.0]" when attempting to use the Proguard or Multidex features in Xamarin.Android. See 44187. I would recommend that you install this on the side of the default version that Android ships in android-sdk\tools\proguard. Simply rename the existing folder to something else and add the new version of proguard.)

1 upvote
  flag
I looked it up and it's pointing to the right location and I only have JDK 7 Installed . – Dikshit Kalra
2 upvote
  flag
Could you please go to... Help > About > Show Details And copy the contents of the Xamarin.Android section please? – Alan Clark
1 upvote
  flag
Xamarin.Android Version: 6.0.2.1 (Starter Edition) Android SDK: C:\Users\Admin\AppData\Local\Android\android-sdk Supported Android versions: 4.0.3 (API level 15) 4.4 (API level 19) 6.0 (API level 23) SDK Tools Version: 24.4.1 SDK Platform Tools Version: 23.0.1 SDK Build Tools Version: 24 rc2 Java SDK: C:\Program Files (x86)\Java\jdk1.7.0_71 java version "1.7.0_71" Java(TM) SE Runtime Environment (build 1.7.0_71-b14) Java HotSpot(TM) Client VM (build 24.71-b01, mixed mode, sharing) Android Designer EPL code available here: github.com/xamarin/AndroidDesigner.EPL – Dikshit Kalra
4 upvote
  flag
Thanks for the version information. The Build Tools Version looks like it might be the problem: "24 rc2". Xamarin.Android is not yet compatible with that build tools version from the "Preview Channel" in the Android SDK Manager. You can uninstall that preview version and install one of the non-preview versions of the Build-tools (such as 23.0.3) using the Android SDK Manager. – Brendan Zagaeski
upvote
  flag
@BrendanZagaeski uninstalling the current preview version just worked . Thanks a ton . – Dikshit Kalra
upvote
  flag
Don't forget to copy the Proguard configuration files from the old directory as well. (i.e. proguard-android.txt, proguard-android-optimize.txt, and proguard-project.txt) – Taylor Buchanan

Unsupported major.minor version 52.0

This error message is caused by an incompatibility with the Java JDK: Android SDK Build-tools versions 24 and higher require Java JDK 8 (1.8), whereas earlier versions were still compatible with Java JDK 7 (1.7). (This resembles older answers about the same error.)

Steps to update:

  1. Update to Java JDK 8. It is recommended to use the 64-bit version for compatibility with the new Xamarin Android designer features in Xamarin Studio 6.1 and Xamarin for Visual Studio 4.2.

  2. Double-check that Java JDK 8 is selected in the Xamarin preferences:

    • Visual Studio: Tools > Options > Xamarin > Android Settings > Java Development Kit Location.

      "Tools > Options > Xamarin > Android Settings > Java Development Kit Location" in Visual Studio

    • Xamarin Studio (on Mac): Xamarin Studio > Preferences > Projects > SDK Locations > Android > Java SDK (JDK).

      "Xamarin Studio > Preferences > Projects > SDK Locations > Android > Java SDK (JDK)"

  3. Install Android SDK Build-tools 24.0.1 or higher.

  4. (Optional) Uninstall the older Android SDK Build-tools 24 that has a bug in aapt:

Alternatives:

If you would rather not update to Java JDK 8 yet, you can instead do one of the following.

  • Uninstall all Android SDK Build-tools versions 24 and higher via the Android SDK manager.

  • Or set the AndroidSdkBuildToolsVersion MSBuild property to an earlier version. For example, if you also have version 23.0.3 installed, you could add the following line within the top <PropertyGroup> element in the Android project .csproj file:

    <AndroidSdkBuildToolsVersion>23.0.3</AndroidSdkBuildToolsVersion>
    

(See also https://releases.xamarin.com/technical-bulletin-android-sdk-build-tools-24/.)


Additional background info

Update July 25, 2016:

Google has now released Android SDK Build-tools 24.0.1. That version fixes a bug in aapt that was present in version 24.


Update July 14, 2016:

Unsupported major.minor version 52.0

It turns out this error message is caused by an incompatibility with the Java JDK rather than with Xamarin.Android: Android SDK Build-tools version 24 requires Java JDK 1.8, whereas earlier versions were still compatible with Java JDK 1.7. (This resembles older answers about the same error.)


Update June 16, 2016:

The non-preview version of Android SDK Build-tools version 24 is now available in the Android SDK Manager. Xamarin.Android is not yet compatible with that version either.


Info from April 12, 2016:

SDK Build Tools Version: 24 rc2

The "Build Tools Version" looks like it might be the problem. Xamarin.Android is not yet compatible with the "24 rc2" Build-tools version from the "Preview Channel" in the Android SDK Manager. You can uninstall that preview version and install one of the non-preview versions of the Build-tools (such as 23.0.3) using the Android SDK Manager.

5 upvote
  flag
Thank you! I was ripping my hair from this problem – Eino Gourdin
upvote
  flag
This worked for me.... Thanks – DJ Burb
1 upvote
  flag
It's not just Android SDK Build Tools 24 rc2. Android SDK Build Tools 24 is also causing this. Moreover, just removing it and rebuilding the project didn't fix the problem for me- I also had to close and reopen Xamarin Studio and "Clean All". – dstrube
upvote
  flag
For me I had to remove (Android SDK Build Tools 24) and (Android SDK Build Tools 24.0.1) and then in Visual studio do (build -> Rebuild solution) – MujtabaFR
upvote
  flag
Incredible answer that solved my issue. Thank you. – Chucky
upvote
  flag
Setting the <AndroidSdkBuildToolsVersion>23.0.3</AndroidSdkBuildToolsVer‌​sion> helped me. Thanks!!! – Vishnu Babu

Make sure that if in VS you go to
Project > Project Name Properties > Application
you have downloaded all of the selected versions in the Android SDK

Let's say that you have only installed the API's for Android 6.0 (Level 23) and 5.1.1 (Level 22), but you are setting your Minimum Android to target to a level below that Level 16 for example. It'll give the java.lang.UnsupportedClassVersionError: error.

Just Make sure you use the correct API Level

Download latest JDK and install,

Then go to:

  • VS2015 Tools > Options > Xamarin and change the java to the latest JDK location.
  • Xamarin Studio: Tools -> Options -> SDK Locations

Hope this helps.

upvote
  flag
That solved, thanks, I also pointed the SDK location to my old SDK wich came with Android Studio and I have much more tools installed there!! – Anaximandro Andrade

As Brendan Zagaeski told,its a problem generated because of using preview version of build tools

Please follow these steps

  • Open SDK manager
  • Select Build tools with version 24rc2 (Please make sure that only this item is selected)
  • Click on uninstall

UPDATE: detailed answer can be found here //allinonescript.com/a/37827161/5073734

**UPDATE 2016 Nov ** Some of my friends told me that it can also happen with the nuget packages. If the above doesn't solve your problems, try to reinstall nuget packages.

I realize this is a little bit older now, but I also ran into this issue and nothing I found online would resolve it. Finally I tried uninstalling and reinstalling some nuget packages I had installed (SQLite.Net). After that it compiled. Hope this is of use to someone who has exhausted these more common solutions.

upvote
  flag
well it's not half bad to bump in an "old" post. specially if the case is not actually closed yet. after adding Android Support Library v4 and Google Play Services - Ads, my project went loco. and i haven't found any decent solution yet – TheQuestioner

I faced the same problem just couple of minutes back. Sure shot solution: a) Go to Tools > Options > Xamarin > Android Settings > Java Development Kit Location > change it to JDK 1.8 Make sure you point to current java version

100 % working

I faced the same issue, my system had java version 1.7 installed. I installed the 1.8 version in system.

Updated path of jdk Tools->Options->Xamarin->android settings->(java development kit location)set jdk path to new jdk version

rebuid project again, problem resolved.

Deleting version 24, downloading and installing JDK 1.8_112, changing the java development kit to JKD 1.8_112 (now found in program files and not program files x86) and rebuilding the project did the trick for me.

SOLUTION!

Change the Java SDK to 1.8.x. After restarting Visual Studio, run "Clean Solution", "Build" and be happy!

enter image description here

1 upvote
  flag
*Step 2: Options... – Jaider
upvote
  flag
Right! The image is slightly higher, but if you look at the window in steps 3 and 4 you will see the "Options" title bar. Thanks for the comment! – Edvaldo Silva

Not the answer you're looking for? Browse other questions tagged or ask your own question.