Quality Catalyst Quality Catalyst - 1 year ago 180
Android Question

Xamarin upgrade causes "class file has wrong version 52.0, should be 50.0" error

I upgraded to the latest version of Xamarin in Visual Studio 2015. I then compiled my Android project and was confronted with this error:

cannot access android.app.Activity bad class file:
class file has wrong version 52.0, should be 50.0 Please remove or
make sure it appears in the correct subdirectory of the classpath.

Searching the internet I only found hints related to Java and different versions of Java compilers, Eclipse etc. Nothing related to Xamarin.

Any idea what is wrong?

Answer Source

The new Xamarin toolset is based on the Java SDK version 1.7 while my previous version was on JDK 1.6. Upgrading Xamarin does not upgrade the preferred JDK hence this needs to be done manually.

In Visual Studio go to Tools >> Options, sroll down to Xamarin >> Android Settings. There you find an option to change the Java Development Kit Location. Click the Change link. In the new dialog click the ... button and select the JDK 1.7. Confirm all dialogues. Done.

enter image description here

Compile your project. The problem should be gone.

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