Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ProGuard says Unsupported class version number [52.0] (maximum 51.0, Java 1.7) with sbt-proguard

Tags:

I'm on Mac OS X 10.9.2 and sbt 0.13.3-SNAPSHOT (built from the sources), Java 8 and sbt-proguard 0.2.2 plugin.

sbt 0.13.3-SNAPSHOT

[jacek]> sbtVersion [info] 0.13.3-SNAPSHOT 

Java 8

$ /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/bin/java -version java version "1.8.0" Java(TM) SE Runtime Environment (build 1.8.0-b132) Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode) 

project/plugins.sbt

addSbtPlugin("com.typesafe.sbt" % "sbt-proguard" % "0.2.2") 

When I ran proguard:proguard in sbt shell it blew up with the following exception:

[sbt-updates]> show proguard:proguard [info] ProGuard, version 4.9 [info] Reading program directory [/Users/jacek/oss/sbt-updates/target/scala-2.10/sbt-0.13/classes] (filtered) [info] Reading program jar [/Users/jacek/.ivy2/cache/org.scalaz/scalaz-concurrent_2.10/bundles/scalaz-concurrent_2.10-7.1.0-M6.jar] (filtered) [info] Reading program jar [/Users/jacek/.sbt/boot/scala-2.10.3/lib/scala-library.jar] (filtered) [info] Reading program jar [/Users/jacek/.ivy2/cache/org.scalaz/scalaz-core_2.10/bundles/scalaz-core_2.10-7.1.0-M6.jar] (filtered) [info] Reading program jar [/Users/jacek/.ivy2/cache/org.scalaz/scalaz-effect_2.10/bundles/scalaz-effect_2.10-7.1.0-M6.jar] (filtered) [info] Reading library jar [/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/rt.jar] [error] Error: Can't read [/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/rt.jar] (Can't process class [apple/applescript/AppleScriptEngine.class] (Unsupported class version number [52.0] (maximum 51.0, Java 1.7))) [trace] Stack trace suppressed: run last proguard:proguard for the full output. [error] (proguard:proguard) Proguard failed with exit code [1] [error] Total time: 16 s, completed Apr 19, 2014 2:27:56 PM 

Why could be the reason for the error?

like image 929
Jacek Laskowski Avatar asked Apr 19 '14 13:04

Jacek Laskowski


2 Answers

It appears that ProGuard and hence sbt-proguard don't support Java 8 yet and changing the version of Java used in the script to launch sbt helped.

[sbt-updates]> show proguard:proguard [info] Compiling 8 Scala sources to /Users/jacek/oss/sbt-updates/target/scala-2.10/sbt-0.13/classes... [warn] there were 6 feature warning(s); re-run with -feature for details [warn] one warning found [info] ProGuard, version 4.9 [info] Reading program directory [/Users/jacek/oss/sbt-updates/target/scala-2.10/sbt-0.13/classes] (filtered) [info] Reading program jar [/Users/jacek/.ivy2/cache/org.scalaz/scalaz-concurrent_2.10/bundles/scalaz-concurrent_2.10-7.1.0-M6.jar] (filtered) ... 

This is with the following version of Java 7:

$ /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java -version java version "1.7.0_51" Java(TM) SE Runtime Environment (build 1.7.0_51-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode) 
like image 168
Jacek Laskowski Avatar answered Sep 28 '22 02:09

Jacek Laskowski


The question is really interesting and i was facing the same problem with the only difference that i added Proguard programmatically by using maven. Consequently, i considered that it will be helpful to post my solution although it is a bit different from the main question. For all those that using maven and faces the same problem, my workaround fix was to update the version of Proguard by using it as runtime inside the plugin, so the working pom.xml looks like this

  <plugin>                     <groupId>com.github.wvengen</groupId>                     <artifactId>proguard-maven-plugin</artifactId>                     <version>2.0.14</version>                     <executions>                         <execution>                             <phase>package</phase>                             <goals>                                 <goal>proguard</goal>                             </goals>                         </execution>                     </executions>                     <configuration>                         <obfuscate>true</obfuscate>                         <attach>true</attach>                         <appendClassifier>false</appendClassifier>                         <addMavenDescriptor>true</addMavenDescriptor>                         <injar>${project.build.finalName}-jar-with-dependencies.jar</injar>                         <injarNotExistsSkip>true</injarNotExistsSkip>                         <libs>                             <lib>${java.home}/lib/rt.jar</lib>                             <lib>${java.home}/lib/jce.jar</lib>                             <lib>${java.home}/lib/ext/sunjce_provider.jar</lib>                         </libs>                         <options>                         <option>-allowaccessmodification</option>                         <option>-optimizationpasses 3</option>                         <option>-overloadaggressively</option>                         <option>-repackageclasses ''</option>                         <option>-dontusemixedcaseclassnames</option>                         <option>-dontskipnonpubliclibraryclasses</option>                         <option>-flattenpackagehierarch</option>                         <option>-dontwarn</option> <!-- added option to ignore com.sun missing classes -->                             <option>-keep public class com.StocksNews.App {                                 public static void main(java.lang.String[]);                                 }                             </option>                         </options>                     </configuration>                     <dependencies>                         <dependency>                             <groupId>net.sf.proguard</groupId>                             <artifactId>proguard-base</artifactId>                             <version>6.1.1</version>                             <scope>runtime</scope>                         </dependency>                     </dependencies>                 </plugin> 
like image 26
Panagiotis Drakatos Avatar answered Sep 28 '22 00:09

Panagiotis Drakatos