0

I'm bringing an old android project back to live and i decided to use maven (m2e-android), works nicely after some fiddling. One problem i'm stil having is that i get a "must override a superclass method" errors, for example on the following code:

new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
        dialog.dismiss();
        act.finish();
    }
}

Of course i browsed around and discovered: 'Must Override a Superclass Method' Errors after importing a project into Eclipse

But this one doesn't say anything about maven.

I know you can specify source and target level in maven in pom.xml like:

<configuration>
    <source>${java.version}</source>
    <target>${java.version}</target>
</configuration>

Works great in normal, non android, projects. But it doesn't seem to have any effects in my android project (also tried updating my maven project, java compiler is also set to 1.6 automatically)

Here is my pom.xml for reference:

<?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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com..bee</groupId>
    <artifactId>client</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>client</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.6</java.version>
        <platform.version>4.1.1.4</platform.version>
        <android.plugin.version>3.9.0-rc.2</android.plugin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>${platform.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            ...
        </dependency>
    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.2</version>
                    <configuration>
                        <source>${java.version}</source>
                        <target>${java.version}</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>${android.plugin.version}</version>
                    <extensions>true</extensions>
                </plugin>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                                        <artifactId>android-maven-plugin</artifactId>
                                        <versionRange>[3.8.0,)</versionRange>
                                        <goals>
                                            <goal>consume-aar</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore />
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>

            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <configuration>
                    <sdk>
                        <platform>16</platform>
                    </sdk>
                </configuration>
            </plugin>

        </plugins>
    </build>
</project>

I suspect i'm missing a small thing. How can i get rid of the "must override a superclass method" without removing the @Override annotation?

Community
  • 1
  • 1
TinusSky
  • 1,657
  • 5
  • 24
  • 32
  • Are you missing the semiColon in your anonymous class? – Jason Jul 07 '14 at 18:05
  • @Jason nope, the code compiles and runs without any problem when not using maven. – TinusSky Jul 07 '14 at 18:15
  • hmm, if you are using Eclipse highlight DialogInterface, press f3, and in Package explorer check which jar its pointing to. Might be an older version of Android that didn't yet have the method to override yet? That's all I can think of. – Jason Jul 07 '14 at 18:22
  • @Jason, cheers for the help, but i get this error all over the place, it is caused because java1.5 didn't support override when implementing function of a interface, 1.6 does support this. See for details the link i provided. – TinusSky Jul 07 '14 at 18:30

1 Answers1

0

A new morning a brand new mind set :-)

I added a space to AndroidManifest.xml and saved the file. This triggered some kind of cache cleanup or eclipse android setting reset and all "must override a superclass method" disappeared.

It seems that my eclipse/android/maven was in a state which was invalid.

TinusSky
  • 1,657
  • 5
  • 24
  • 32