-1

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>
Stefan S.
  • 3,950
  • 5
  • 25
  • 77

2 Answers2

0

You have to make sure the the version of the application you want to test is correct. In your case you are using version 1.0.0 ... while in reality the latest version under development is probably something like 1.1.0-SNAPSHOT.

Also you pom above is definitely invalid. Look at the samples project we provide as part of the Android Maven Plugin project.

Manfred Moser
  • 29,539
  • 13
  • 92
  • 123
  • I'm using `${project.version}` so that cannot be the problem. I would have gotten errors after deleting the Maven repositories, too. And of course this _pom.xml_ is invalid. I tried to show all the relevant data, and I don't think the actual _pom.xml_ is of any help, since it was auto-generated by the archetype. – Stefan S. Jun 15 '14 at 08:35
  • Have you compared the setup to one of the samples projects like morseflash? – Manfred Moser Jun 16 '14 at 02:31
  • The only difference is the dependency of type "apk", but adding it makes the build fail with a different error message of the meaningless kind ("Unable to resolve activity for: Intent") – Stefan S. Jun 16 '14 at 13:53
  • You have to have the apk as a dependency.. Use the latest version of the plugin and let us know more details in a bug report potentially. – Manfred Moser Jun 16 '14 at 20:09
0

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.

Stefan S.
  • 3,950
  • 5
  • 25
  • 77