我在Mac OS X 10.9.2和sbt 0.13.3-SNAPSHOT(从源构建),Java8和sbt-proGuard 0.2.2插件。
sbt 0.13。三维快照
[jacek]> sbtVersion
[info] 0.13.3-SNAPSHOT
爪哇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)
项目/插件。sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-proguard" % "0.2.2")
当我在sbt shell中运行proguard:proguard
时,它发生了以下异常:
[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
为什么可能是错误的原因?
通过更改build中的键
设置为高于5.0的设置,例如。proguardVersion
,可以更新sbt Proguard使用的Proguard版本。sbt
ProguardKeys.proguardVersion in Proguard := "5.2.1"
见:https://github.com/sbt/sbt-proguard/issues/5
这个问题真的很有趣,我面临着同样的问题,唯一的区别是我通过使用maven以编程方式添加了ProGuard。因此,我认为把我的解决方案贴出来会有帮助,尽管它与主要问题有点不同。对于所有使用maven并面临同样问题的人,我的解决方案是通过在插件中使用ProGuard作为运行时来更新它的版本,所以工作pom.xml如下所示
<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>
ProGuard和sbt ProGuard似乎还不支持Java 8,因此更改脚本中使用的Java版本以启动sbt很有帮助。
[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)
...
这适用于以下版本的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)
我试图在我的Xamarin.Android项目中使用Proguard,但是编译失败,出现错误 Java.io.ioException:无法读取[/library/frameworks/xamarin.android.framork/versions/7.0.0-18/lib/xbuild-frameworks/monoandroid/v7.0/mono.android.jar](无法处理类[And
不识字 [C:\计划文件(x86)\参考程序集\微软\框架\MonoAndroid\v7.0\mono.android.jar](无法处理类[android/app/ActivityTracker.class](不支持的类版本号[52.0](最大51.0,Java1.7)) 如何解决这个问题。。??
以前的解决方案建议: 升级Java运行时或 如果有源代码,请使用本地Java编译器(如果有)重新编译该类。 @Brad Parks-https://stackoverflow.com/users/26510/Brad-Parks 由于无法重新编译产生错误的文件,我尝试将我的JRE从JSK1.6升级到JDK1.8-这现在产生了错误: 我对Java还很陌生,所以我可能忽略/误解了一些东西
当我试图用proguard混淆某个应用程序时,我总是会遇到这种错误 我已经更新了Proguard并检查了项目配置文件,但总是出现相同的错误。我正在使用Intellij IDEA的最新版本
我已经下载了程序: 解压缩它: 进入文件夹并运行: 这是我得到的错误: 我这样做过: 但是同样的错误 我的java版本: javac1.6。0_35 Java版本"1.6.0_35"OpenJDK运行时环境(IcedTea6 1.13.7) (6b35-1.13.7-1~Deb7u1)OpenJDK 64位服务器VM(build 23.25-b01,混合模式) 我读到这篇文章是因为我编译的版本比J
我的pom.xml: 似乎所有的设置都是正确的,我指的是在pom和服务器上的java版本。