ProGuard:"不支持的版本号[52.0]"使用正确的Java版本

时间:2014-05-13 09:06:47

标签: java maven obfuscation proguard

在尝试混淆我的Java程序时,出现以下错误(运行mvn clean install):

[INFO] --- proguard-maven-plugin:2.0.4:proguard (default) @ myproduct ---
[INFO] execute ProGuard [-injars, 'D:\dev\myproduct\target\myproduct-1.0.6_proguard_base.jar'(!META-INF/maven/**), -outjars, 'D:\dev\myproduct\target\myproduct-1.0.6.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\org\easytesting\fest-util\1.2.3\fest-util-1.2.3.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\org\powermock\powermock-api-support\1.5.1\powermock-api-support-1.5.1.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\org\powermock\powermock-reflect\1.5.1\powermock-reflect-1.5.1.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\org\objenesis\objenesis\1.2\objenesis-1.2.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\org\powermock\powermock-core\1.5.1\powermock-core-1.5.1.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\org\javassist\javassist\3.18.0-GA\javassist-3.18.0-GA.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\org\easytesting\fest-assert-core\2.0M8\fest-assert-core-2.0M8.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\com\google\guava\guava\15.0\guava-15.0.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\org\mockito\mockito-all\1.9.5\mockito-all-1.9.5.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\com\h2database\h2\1.3.173\h2-1.3.173.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\ru\mycompany\commons\2.9\commons-2.9.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\commons-lang\commons-lang\2.5\commons-lang-2.5.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\com\google\inject\guice\2.0\guice-2.0.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\org\slf4j\slf4j-api\1.6.1\slf4j-api-1.6.1.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.1.4\jackson-core-2.1.4.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.1.4\jackson-databind-2.1.4.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.1.4\jackson-annotations-2.1.4.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\org\easymock\easymock\3.2\easymock-3.2.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\cglib\cglib-nodep\2.2.2\cglib-nodep-2.2.2.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\ch\qos\logback\logback-core\0.9.26\logback-core-0.9.26.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\ch\qos\logback\logback-classic\0.9.26\logback-classic-0.9.26.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\net\sf\opencsv\opencsv\2.0\opencsv-2.0.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\org\jgrapht\jgrapht-jdk1.5\0.7.3\jgrapht-jdk1.5-0.7.3.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\jgraph\jgraph\5.13.0.0\jgraph-5.13.0.0.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\com\googlecode\soundlibs\jlayer\1.0.1-1\jlayer-1.0.1-1.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\com\javadocmd\simplelatlng\1.3.0\simplelatlng-1.3.0.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\se\kodapan\osm\common\core\0.0.2-SNAPSHOT\core-0.0.2-SNAPSHOT.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\org\json\json\20090211\json-20090211.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\org\apache\commons\commons-lang3\3.1\commons-lang3-3.1.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\se\kodapan\osm\common\java\0.0.2-SNAPSHOT\java-0.0.2-SNAPSHOT.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\org\apache\lucene\lucene-core\4.5.0\lucene-core-4.5.0.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\org\apache\lucene\lucene-analyzers-common\4.5.0\lucene-analyzers-common-4.5.0.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\org\apache\httpcomponents\httpclient\4.1.2\httpclient-4.1.2.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\org\apache\httpcomponents\httpcore\4.1.2\httpcore-4.1.2.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\commons-codec\commons-codec\1.4\commons-codec-1.4.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\commons-io\commons-io\2.3\commons-io-2.3.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\org\javatuples\javatuples\1.2\javatuples-1.2.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\com\vividsolutions\jts\1.12\jts-1.12.jar', -libraryjars, 'C:\Users\MYUSER\.m2\repository\xerces\xercesImpl\2.4.0\xercesImpl-2.4.0.jar', -libraryjars, 'C:\Program Files\Java\jdk1.8.0\jre/lib/rt.jar', -printmapping, 'D:\dev\myproduct\target\proguard_map.txt', -printseeds, 'D:\dev\myproduct\target\proguard_seeds.txt', -allowaccessmodification]
[INFO] proguard jar: C:\Users\MYUSER\.m2\repository\net\sf\proguard\proguard\4.3\proguard-4.3.jar
 [proguard] ProGuard, version 4.3
 [proguard] Reading program jar [D:\dev\myproduct\target\myproduct-1.0.6_proguard_base.jar] (filtered)
 [proguard] Error: Can't read [D:\dev\myproduct\target\myproduct-1.0.6_proguard_base.jar(;;;;!META-INF/maven/**)] (Can't process class [com/roots/map/MapApplet.class] (Unsupported version number [52.0] for class format))

有些人建议我查看我正在使用的Java版本。 mvn -version返回此信息:

D:\dev\myproduct>mvn -version
Apache Maven 3.0.4 (r1232337; 2012-01-17 12:44:56+0400)
Maven home: C:\Program Files\apache-maven-3.0.4
Java version: 1.8.0-ea, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0\jre
Default locale: de_AT, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "dos"

这似乎是正确的。

我该怎么做才能解决此错误?

请注意,com/roots/map/MapApplet是开源库的一部分,因此没有必要对其进行模糊处理。如果可以将该类排除在讨论之外,我想这样做。

以下是我的pom.xml

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>ru.mycompany</groupId>
    <artifactId>myproduct</artifactId>
    <version>1.0.6</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <powermock.version>1.5.1</powermock.version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>com.pyx4me</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals><goal>proguard</goal></goals>
                    </execution>
                </executions>
                <configuration>
                    <options>
                        <option>-allowaccessmodification</option>
                    </options>
                    <libs>
                        <lib>${java.home}/lib/rt.jar</lib>
                    </libs>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.easytesting</groupId>
            <artifactId>fest-util</artifactId>
            <version>1.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-support</artifactId>
            <version>1.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-reflect</artifactId>
            <version>1.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-core</artifactId>
            <version>1.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.easytesting</groupId>
            <artifactId>fest-assert-core</artifactId>
            <version>2.0M8</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>15.0</version>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.9.5</version>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.3.173</version>
        </dependency>
        <dependency>
            <groupId>ru.mycompany</groupId>
            <artifactId>commons</artifactId>
            <version>2.9</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4</artifactId>
            <version>${powermock.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito</artifactId>
            <version>${powermock.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymock</artifactId>
            <version>3.2</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-easymock</artifactId>
            <version>${powermock.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>0.9.26</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>0.9.26</version>
        </dependency>
        <dependency>
            <groupId>net.sf.opencsv</groupId>
            <artifactId>opencsv</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>org.jgrapht</groupId>
            <artifactId>jgrapht-jdk1.5</artifactId>
            <version>0.7.3</version>
        </dependency>
        <dependency>
            <groupId>jgraph</groupId>
            <artifactId>jgraph</artifactId>
            <version>5.13.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.soundlibs</groupId>
            <artifactId>jlayer</artifactId>
            <version>1.0.1-1</version>
        </dependency>
        <dependency>
            <groupId>com.javadocmd</groupId>
            <artifactId>simplelatlng</artifactId>
            <version>1.3.0</version>
        </dependency>
        <!-- Overpass stuff (start) -->
        <dependency>
            <groupId>se.kodapan.osm.common</groupId>
            <artifactId>core</artifactId>
            <version>0.0.2-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>se.kodapan.osm.common</groupId>
            <artifactId>java</artifactId>
            <version>0.0.2-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.1.2</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.3</version>
        </dependency>
        <!-- Overpass stuff (end) -->
        <dependency>
            <groupId>org.javatuples</groupId>
            <artifactId>javatuples</artifactId>
            <version>1.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.vividsolutions</groupId>
            <artifactId>jts</artifactId>
            <version>1.12</version>
        </dependency>
    </dependencies>
</project>

更新1:修改后的POM与ProGuard相关。

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>ru.mycompany</groupId>
    <artifactId>myproduct</artifactId>
    <version>1.0.6</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <powermock.version>1.5.1</powermock.version>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.wvengen</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <version>2.0.7</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals><goal>proguard</goal></goals>
                    </execution>
                </executions>
                <configuration>
                    <proguardVersion>5.0beta1</proguardVersion>
                    <options>
                        <option>-allowaccessmodification</option>
                        <option>-dontshrink</option>
                        <option>-dontoptimize</option>
                        <option>-dontpreverify</option>
                        <option>-dontnote</option>
                        <option>-keep ru.mycompany.ccp.myproduct.myproductApp</option>
                    </options>
                    <libs>
                        <lib>${java.home}/lib/rt.jar</lib>
                    </libs>
                    <dependencies>
                        <dependency>
                            <groupId>net.sf.proguard</groupId>
                            <artifactId>proguard-base</artifactId>
                            <version>5.0beta1</version>
                            <scope>runtime</scope>
                        </dependency>
                    </dependencies>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.easytesting</groupId>
            <artifactId>fest-util</artifactId>
            <version>1.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-support</artifactId>
            <version>1.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-reflect</artifactId>
            <version>1.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-core</artifactId>
            <version>1.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.easytesting</groupId>
            <artifactId>fest-assert-core</artifactId>
            <version>2.0M8</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>15.0</version>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.9.5</version>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.3.173</version>
        </dependency>
        <dependency>
            <groupId>ru.mycompany</groupId>
            <artifactId>commons</artifactId>
            <version>2.9</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4</artifactId>
            <version>${powermock.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito</artifactId>
            <version>${powermock.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymock</artifactId>
            <version>3.2</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-easymock</artifactId>
            <version>${powermock.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>0.9.26</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>0.9.26</version>
        </dependency>
        <dependency>
            <groupId>net.sf.opencsv</groupId>
            <artifactId>opencsv</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>org.jgrapht</groupId>
            <artifactId>jgrapht-jdk1.5</artifactId>
            <version>0.7.3</version>
        </dependency>
        <dependency>
            <groupId>jgraph</groupId>
            <artifactId>jgraph</artifactId>
            <version>5.13.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.soundlibs</groupId>
            <artifactId>jlayer</artifactId>
            <version>1.0.1-1</version>
        </dependency>
        <dependency>
            <groupId>com.javadocmd</groupId>
            <artifactId>simplelatlng</artifactId>
            <version>1.3.0</version>
        </dependency>
        <!-- Overpass stuff (start) -->
        <dependency>
            <groupId>se.kodapan.osm.common</groupId>
            <artifactId>core</artifactId>
            <version>0.0.2-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>se.kodapan.osm.common</groupId>
            <artifactId>java</artifactId>
            <version>0.0.2-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.1.2</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.3</version>
        </dependency>
        <!-- Overpass stuff (end) -->
        <dependency>
            <groupId>org.javatuples</groupId>
            <artifactId>javatuples</artifactId>
            <version>1.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.vividsolutions</groupId>
            <artifactId>jts</artifactId>
            <version>1.12</version>
        </dependency>
    </dependencies>
</project>

0 个答案:

没有答案