gpt4 book ai didi

java - Maven Android : java. lang.UnsupportedClassVersionError : com/android/dx/command/Main : Unsupported major. 次要版本 52.0

转载 作者:行者123 更新时间:2023-12-02 13:07:25 25 4
gpt4 key购买 nike

当我尝试使用以下内容构建我的 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

最佳答案

错误java.lang.UnsupportedClassVersionError:com/android/dx/command/Main:不支持的major.minor版本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>

关于java - Maven Android : java. lang.UnsupportedClassVersionError : com/android/dx/command/Main : Unsupported major. 次要版本 52.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44089215/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com