Xamarin.Android Proguard - Unsupported class version number 52.0

Eino Gourdin picture Eino Gourdin · Sep 15, 2016 · Viewed 29.2k times · Source

I'm trying to use Proguard in my Xamarin.Android project, yet the compilation fails with the error Unsupported class version number [52.0] (maximum 51.0, Java 1.7)

I saw from those two questions that it may be a mismatch between Java 7 and Java 8, more precisely some versions of proguard don't support Java 8. However in Xamarin Preferences -> SDK Location, Java SDK points to JDK 7 : /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home

Is there any place where proguard can be configured more precisely ? Any other idea ?

Here's the failure log :

java.io.IOException: Can't read [/Library/Frameworks/Xamarin.Android.framework/Versions/7.0.0-18/lib/xbuild-frameworks/MonoAndroid/v7.0/mono.android.jar] (Can't process class [android/app/ActivityTracker.class] (Unsupported class version number [52.0] (maximum 51.0, Java 1.7))) at proguard.InputReader.readInput(InputReader.java:230) at proguard.InputReader.readInput(InputReader.java:200) at proguard.InputReader.readInput(InputReader.java:178) at proguard.InputReader.execute(InputReader.java:78) at proguard.ProGuard.readInput(ProGuard.java:196) at proguard.ProGuard.execute(ProGuard.java:78) at proguard.ProGuard.main(ProGuard.java:492) Caused by: java.io.IOException: Can't process class [android/app/ActivityTracker.class] (Unsupported class version number [52.0] (maximum 51.0, Java 1.7)) at proguard.io.ClassReader.read(ClassReader.java:112) at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87) at proguard.io.JarReader.read(JarReader.java:65) at proguard.io.DirectoryPump.readFiles(DirectoryPump.java:65) at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:53) at proguard.InputReader.readInput(InputReader.java:226) ... 6 more Caused by: java.lang.UnsupportedOperationException: Unsupported class version number [52.0] (maximum 51.0, Java 1.7) at proguard.classfile.util.ClassUtil.checkVersionNumbers(ClassUtil.java:140) at proguard.classfile.io.ProgramClassReader.visitProgramClass(ProgramClassReader.java:88) at proguard.classfile.ProgramClass.accept(ProgramClass.java:346) at proguard.io.ClassReader.read(ClassReader.java:91) ... 11 more

9 Warning(s) 1 Error(s)

Answer

Jon Douglas picture Jon Douglas · Sep 15, 2016

You need to update the default Android SDK proguard.jar with the latest version of Proguard found here:

https://sourceforge.net/projects/proguard/files/

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.

This is listed in the Xamarin.Android 7.0 release notes:

https://developer.xamarin.com/releases/android/xamarin.android_7/xamarin.android_7.0/

In which the following bug was logged as well:

https://bugzilla.xamarin.com/show_bug.cgi?id=44187

Which is coordinated with a Pull Request in the Xamarin.Android repository:

https://github.com/xamarin/xamarin-android/pull/209