Search code examples
androidmavenandroid-maven-plugin

Android Integration Test Uses Old APK


I've created a beautiful Android project using Maven and the Android-Release Archetype. Now I have a simple problem: My integration tests don't use the newest version of my library under test.

When run Eclipse, Maven and M2E all seem to use an obsolete version (at least the app opened on my device for a split second looks that way). I first thought it might be Eclipse's stupid caching, but then Maven should be able to use the correct version. I deleted the bin and target folders and even the entries in the Maven repositories, but the build always pulls that old version out of thin air.

And just now I found that not only is the library under test obsolete, but there is a test executed via Maven and M2E that was deleted some time ago.

I know the question is pretty vague, but I'm not sure where to look for the source of the problem. Can anyone give me a pointer to what is happening?


Evidently these are at least two separate problems. I fixed the Eclipse portion by adding the library as dependency in the Android properties of the project. Since it's a problem with the android-maven-plugin now I'll post the relevant parts of the pom.xml of the integration test project in hopes that someone starting from the same archetype had the same problem and knows how to fix it:

<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>
<artifactId>org.acme.project.android.it</artifactId>
<packaging>apk</packaging>

<dependencies>
    <dependency>
        <groupId>org.acme.project</groupId>
        <artifactId>org.acme.project.android</artifactId>
        <version>${project.version}</version> 
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android-test</artifactId>
        <version>4.1.1.4</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

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

Solution

  • The correct answer is: What I wanted to do (integration testing an Android library) is just not possible. I now test the app and it works.