24

I get always this erroe when I try to obfuscate an App with proguard

Error:ProGuard: [MyApp] java.io.IOException: Can't read [C:\Program Files\Java\jdk1.8.0\jre\lib\rt.jar] (Can't process class [com/oracle/net/Sdp$1.class] (Unsupported class version number [52.0] (maximum 51.0, Java 1.7)))

I have already updated Proguard and checked the project-config file but always the same Error. I'm using the latest version of Intellij IDEA

AndreaF
  • 11,975
  • 27
  • 102
  • 168

4 Answers4

26

Seems that Proguard doesn't support Java 8 actually. You have to use JDK version 7.

EDIT-1

I have recompiled Proguard to support JDK 8 classes, doesn't support Java 8 new features but if your code doesn't use Java 8 new syntax(e.g. Lambda Expression) should works without problems. Tested with some android projects.

To use replace the file proguard.jar in

android-sdk\tools\proguard\ 

with the content of THIS ARCHIVE

EDIT-2

Recently has been released the official Proguard 5 that should address the issue. You can download this from HERE

Silverstorm
  • 15,398
  • 2
  • 38
  • 52
  • I just tried this and got `java.lang.IllegalArgumentException: Value is not a reference value [proguard.evaluation.value.InstructionOffsetValue]`. – WonderCsabo Apr 21 '14 at 23:59
  • @WonderCsabo Have you replaced the proguard.jar in `android-sdk\tools\proguard\lib`? I'm using this from a month without any problems. NOTE I'm assuming that the Proguard version were you replace this file is the stable 4.11 downloaded from source-forge http://sourceforge.net/projects/proguard/files/proguard/ and you are using official Oracle Java JDK 1.8 – Silverstorm Apr 24 '14 at 00:26
  • I have just added the whole proguard folder to avoid version mismatch – Silverstorm Apr 24 '14 at 00:59
  • Thanks for the answer! I am using the ProGuard version packaged with the Android SDK, it's 4.7. I'll update to the 4.11 version and try your lib again. – WonderCsabo Apr 24 '14 at 07:58
  • Unfortunately i still got the same error. [This](https://gist.github.com/WonderCsabo/11249889) is the trace. I am on Windows 8.1. – WonderCsabo Apr 24 '14 at 10:41
  • Damn... The unmodified ProGuard 4.11 also reproduce my issue... [This](http://sourceforge.net/p/proguard/bugs/505/?limit=25) is a known ProGuard bug which will be fixed. – WonderCsabo Apr 24 '14 at 10:45
  • Ah ok. I have only added the ability to tolerate the new JDK if the code doesn't use the new Java 8 syntax, all others issues present in the 4.11 are the same. – Silverstorm May 02 '14 at 19:28
  • hello, how can I install the proguard 5.2.1? – Fran_gg7 Jul 01 '16 at 15:21
10

ProGuard 5.0 (released in August 2014) supports Java 8.

Eric Lafortune
  • 45,150
  • 8
  • 114
  • 106
2

ProGuard has not been updated yet to support Java 8.

An issue has already been raised against ProGuard.

Eric Lafortune (ProGuard developer) noted back in October 2013

I'm very busy at the moment, so realistically I won't be able to complete this in the short term, sorry. I'm keeping an eye on the developments though.

He also said

ProGuard probably works on class files that only use older features if you change or disable ClassUtil#checkVersionNumbers.

zmarties
  • 4,809
  • 22
  • 39
0

There is a successor of pyx4me ProGuard Maven plugin on github with support to ProGuard 5.2, hence Java 8 support:

https://github.com/wvengen/proguard-maven-plugin

http://wvengen.github.io/proguard-maven-plugin/

Cheers, Ekho

ekho
  • 1