1

while building my app today this error Source option 5 is no longer supported. Use 6 or later. Target option 1.5 is no longer supported. Use 1.6 or later was shown, and cannot fix it because pom.xml file is read-only in android studio. So, can anyone tell me how to fix it????

This is my pom.xml file

<?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>

if i had missed something or you need any other file code to solve this problem please reach out. Because i have no idea where this error is coming from.

Rishu_974
  • 41
  • 1
  • 6

2 Answers2

2

Your pom.xml contains the following snippet:

  <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>

This is instructing the compiler that you're using Java 1.5, a pretty ancient version of Java. To comply with the statement that you need to use at least 1.6, change it to:

  <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>

Though 1.6 is also pretty old, a more modern version is highly recommended.

Jeroen Steenbeeke
  • 3,884
  • 5
  • 17
  • 26
  • Yes i know that, but the problem is i don't know how to change it, because as the file is read only so i can not simply type the latest version. Can you tell me how to upgrade to latest version – Rishu_974 Jun 06 '21 at 11:23
  • Yes, it is read-only in android studio. That's the problem. Is there by any means i can change its content? – Rishu_974 Jun 07 '21 at 10:59
  • You seem to have missed the key word in my question: *why* – Jeroen Steenbeeke Jun 07 '21 at 11:12
  • I don't know, maybe this is how it suppose to be. I have no idea but because of this problem i'm stuck can't do anything. – Rishu_974 Jun 07 '21 at 11:19
  • Your project `pom.xml` is not supposed to be read-only. Generally speaking you make changes to this file on a regular basis (such as whenever you add or upgrade a dependency). So my first suggestion would be to check the file attributes and either remove any read-only flags or add write rights (depending on your operating system) – Jeroen Steenbeeke Jun 07 '21 at 11:26
  • 1
    Thanks for the advice mate, The problem is finally solved. – Rishu_974 Jun 08 '21 at 11:41
2

Finally Solved it. It is right that the POM.xml file was read-only, but we can still change the Source compatibility and Target compatibility. The way to do it is as follows:

*Go to: *

File<Project Structure<Modules<Properties

In Properties change the Source Compatibility and Target Compatibility to latest version

Form there it will automatically Update the POM.xml file, you don't have to edit it manually.

Rishu_974
  • 41
  • 1
  • 6