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

前端 未结 4 1154
被撕碎了的回忆
被撕碎了的回忆 2020-12-10 10:41

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 p

相关标签:
4条回答
  • 2020-12-10 11:12

    It's possible to update the version of Proguard that sbt-proguard uses by changing the key proguardVersion in build.sbt to a setting newer than 5.0, e.g.

    ProguardKeys.proguardVersion in Proguard := "5.2.1"
    

    See: https://github.com/sbt/sbt-proguard/issues/5

    0 讨论(0)
  • 2020-12-10 11:17

    I fixed that by update to latest version of ProGuad from link below

    Sourceforge ProGuard page

    0 讨论(0)
  • 2020-12-10 11:19

    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)
    
    0 讨论(0)
  • 2020-12-10 11:21

    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>
    
    0 讨论(0)
提交回复
热议问题