如何解决不再支持源选项 5使用 6 或更高版本的 Android studio
今天构建我的应用程序时出现此错误 不再支持源选项 5。使用 6 或更高版本。 不再支持目标选项 1.5。使用 1.6 或更高版本 已显示,无法修复,因为 pom.xml 文件在 android studio 中是只读的。那么,谁能告诉我如何解决它????
这是我的 pom.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>13.0</version>
<packaging>jar</packaging>
<name>IntelliJ IDEA Annotations</name>
<description>A set of annotations used for code inspection support and code documentation.</description>
<url>http://www.jetbrains.org</url>
<licenses>
<license>
<name>The Apache Software License,Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
<scm>
<url>https://github.com/JetBrains/intellij-community</url>
<connection>scm:git:https://github.com/JetBrains/intellij-community.git</connection>
</scm>
<developers>
<developer>
<id>JetBrains</id>
<name>JetBrains Team</name>
<organization>JetBrains</organization>
<organizationUrl>http://www.jetbrains.com</organizationUrl>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<tasks>
<delete dir="${basedir}/src/main/java" />
<mkdir dir="${basedir}/src/main/java" />
<copy todir="${basedir}/src/main/java">
<fileset dir="${basedir}/../../../community/platform/annotations/src" />
</copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.4</version>
<configuration>
<keyname>66770193</keyname>
<homedir>${basedir}/.gnupg</homedir>
</configuration>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>sonatype-nexus-staging</id>
<url>http://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
如果我遗漏了什么,或者您需要任何其他文件代码来解决这个问题,请联系。因为我不知道这个错误是从哪里来的。
解决方法
您的 pom.xml
包含以下代码段:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
这指示编译器您正在使用 Java 1.5,这是一个非常古老的 Java 版本。符合要求至少使用1.6的说法,改成:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
虽然 1.6 也很旧,但强烈建议使用更现代的版本。
,终于解决了。 POM.xml 文件是只读的是对的,但是我们仍然可以更改 Source 兼容性和 Target 兼容性。方法如下:
*转到:*
文件
在属性中将源兼容性和目标兼容性更改为最新版本
在那里它会自动更新 POM.xml 文件,您不必手动编辑它。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。