Maven Android:java.lang.UnsupportedClassVersionError:com / android / dx / command / Main:不支持的major.minor版本52.0

时间:2017-05-20 18:03:04

标签: java android maven maven-3

当我尝试使用以下内容构建我的android项目时:

Maven :apache-maven-3.3.9,

JDK :jdk1.7.0_79

我收到以下错误:

java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0
  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
  at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
  at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
  at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

有人可以帮忙吗?

谢谢。

我的pom如下:

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.concretepage</groupId>
    <artifactId>AndroidDemo</artifactId>
    <version>1</version>
    <packaging>apk</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>4.1.1.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.android</groupId>
            <artifactId>spring-android-rest-template</artifactId>
            <version>1.0.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.simpleframework</groupId>
            <artifactId>simple-xml</artifactId>
            <version>2.7.1</version>
            <exclusions>
                <exclusion>
                    <artifactId>stax</artifactId>
                    <groupId>stax</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>stax-api</artifactId>
                    <groupId>stax</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>xpp3</artifactId>
                    <groupId>xpp3</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>xmlParserAPIs</artifactId>
                    <groupId>xerces</groupId>
                </exclusion>
            </exclusions>
        </dependency>    
    </dependencies>

    <build>
        <plugins>            
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
              <plugin>
                <groupId>com.simpligility.maven.plugins</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>4.4.3</version>
                <configuration>
                    <sdk>
                        <platform>23</platform>
                    </sdk>
                    <deleteConflictingFiles>true</deleteConflictingFiles>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                    <resourceDirectory>${basedir}/res</resourceDirectory>
                    <androidManifestFile>${basedir}/AndroidManifest.xml</androidManifestFile>
                </configuration>
                <extensions>true</extensions>
              </plugin>
        </plugins>
    </build>

</project>

项目结构如下:

enter image description here

1 个答案:

答案 0 :(得分:1)

错误java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0表示您的某个依赖项中包含的类 com.android.dx.command.Main 是使用Java 1.8(版本52.0)编译的

更改为Java 1.8,应该可以正常工作

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>