1

When I want to run an app on my test phone (Samsung Galaxy S4 Mini) Visual Studio gives me the following error: 1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2066,3): error : java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0 ' What can I do to solve this?

Bowis
  • 541
  • 8
  • 31

1 Answers1

2

TL;DR: You're using the wrong JDK version.


Full answer:

The issue is because of Java version mismatch.

Referring to the Wikipedia Java Class Reference :

J2SE 8 = 52

J2SE 7 = 51

J2SE 6.0 = 50

J2SE 5.0 = 49

JDK 1.4 = 48

JDK 1.3 = 47

JDK 1.2 = 46

JDK 1.1 = 45

These are the reported major numbers. The error regarding the unsupported major.minor version is because during compile time you are using a higher JDK and a lower JDK during runtime.

Thus, the 'major.minor version 52.0' error is possibly because the jar is compiled in jdk 1.8, but you are trying to run it in jdk 1.7 environment. To solve this, it's always better to have the jdk and jre pointed to the same version.


References

Community
  • 1
  • 1
Luís Brito
  • 1,652
  • 1
  • 17
  • 34
  • 1
    So what do I do to solve this? Download the 1.7 JDK? Sorry for all the questions, I'm new to this. – Bowis Nov 26 '16 at 09:56
  • 1
    So I deleted the JDK 1.7 files and now the output gives me a different error: >The $(TargetFrameworkVersion) for Practicum 1.2.dll (v7.0) is greater than the $(TargetFrameworkVersion) for your project (v5.1). You need to increase the $(TargetFrameworkVersion) for your project. 1> Processing: obj\Debug\res\layout\main.xml – Bowis Nov 26 '16 at 10:21
  • 1
    So it looks like my VS keeps using Android 7 as target framework, but I need 5.1 – Bowis Nov 26 '16 at 10:21
  • 1
    I don't know a lot about Xamarin + VS in Android Development, but in native the SDK versions are handled in the Android SDK Manager, so you should be looking for something like "SDK Manager" -> https://developer.xamarin.com/recipes/cross-platform/ide/launch_sdk_manager/ – Luís Brito Nov 26 '16 at 17:24