Dikshit Kalra Dikshit Kalra - 1 year ago 200
Android Question

java Lang UnsupportedClassVersion Error in Xamarin Studio

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: (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)

Answer Source

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.)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download