Alright.
I'm attempting to create a project which is perfectly build able by using maven, and maven only.
Currently I'm facing this issue of classes being generated, and working fine, as long as there is no reference in actual java code.
Meaning, that if I create an example as in the documentation it works.
As soon as I do something like
Intent i = new Intent(SettingsActivity_);
then the build fails with
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project InterestingFind:
Compilation failure cannot find symbol
cannot find symbol
symbol: variable DerpActivity_
location: class be.company.android.DisplayMapActivity
The files however, do get generated, as you can see in the image attached, but when the project is looked at in en Eclipse view, they are solely seen as normal folders, and not as 'source folder'.
This might explain why they are not picked up, but gives me a bit of a headache.
I cloned an android archetype, the release build.
Please, be of assistance if you in some way think you can aid me with this problem!
http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
<parent>
<groupId>be.idamediafoundry</groupId>
<artifactId>InterestingFind-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>be.idamediafoundry</groupId>
<artifactId>InterestingFind</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>InterestingFind - Application</name>
<properties>
<androidannotations.version>3.0-SNAPSHOT</androidannotations.version>
</properties>
<repositories>
<repository>
<id>snapshots-repository</id>
<name>Sonatype oss snapshot repo</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
</dependency>
<dependency>
<groupId>de.akquinet.android.androlog</groupId>
<artifactId>androlog</artifactId>
</dependency>
<!-- JSON -->
<dependency>
<groupId> org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.5</version>
</dependency>
<!-- AndroidAnnotations -->
<dependency>
<groupId>org.androidannotations</groupId>
<artifactId>androidannotations</artifactId>
<version>${androidannotations.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.androidannotations</groupId>
<artifactId>androidannotations-api</artifactId>
<version>${androidannotations.version}</version>
</dependency>
<!-- Needed for androidannotations -->
<dependency>
<groupId>org.springframework.android</groupId>
<artifactId>spring-android-rest-template</artifactId>
<version>${spring-android-version}</version>
</dependency>
<!-- Google Play Services : Should be compiled and added to local repo -->
<dependency>
<groupId>com.google.android.gms</groupId>
<artifactId>google-play-services</artifactId>
<version>5</version>
<type>apklib</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.5.1</version>
<inherited>true</inherited>
<extensions>true</extensions>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
<sdk>
<platform>15</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
</plugin>
<plugin>
<artifactId>versions-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<version>2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<additionalProjectnatures>
<projectnature>com.android.ide.eclipse.adt.AndroidNature</projectnature>
<projectnature>org.eclipse.jdt.core.javanature</projectnature>
</additionalProjectnatures>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.pyx4me</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<executions>
<execution>
<id>process-classes-with-proguard</id>
<phase>process-classes</phase>
<goals>
<goal>proguard</goal>
</goals>
<configuration>
<proguardVersion>4.4</proguardVersion>
<maxMemory>256m</maxMemory>
<injar>classes</injar>
<libs>
<lib>${rt.jar.path}</lib>
<lib>${jsse.jar.path}</lib>
</libs>
<obfuscate>true</obfuscate>
<addMavenDescriptor>false</addMavenDescriptor>
<proguardInclude>${project.basedir}/proguard.conf</proguardInclude>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard</artifactId>
<version>4.4</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-jarsigner-plugin</artifactId>
<executions>
<execution>
<id>sign-application-apk</id>
<phase>package</phase>
<goals>
<goal>sign</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<executions>
<execution>
<id>zipalign-application-apk</id>
<phase>package</phase>
<goals>
<goal>zipalign</goal>
</goals>
</execution>
</executions>
<configuration>
<release>true</release>
<zipalign>
<verbose>true</verbose>
<inputApk>${project.build.directory}/${project.artifactId}-${project.version}.apk</inputApk>
<outputApk>${project.build.directory}/${project.artifactId}-${project.version}-signed-aligned.apk</outputApk>
</zipalign>
<sign>
<debug>false</debug>
</sign>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/proguard_map.txt</file>
<type>map</type>
<classifier>release</classifier>
</artifact>
</artifacts>
</configuration>
<executions>
<execution>
<id>attach-signed-aligned</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
</execution>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/target/generated-sources/annotations</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Parent Pom :
http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
<groupId>be.idamediafoundry</groupId>
<artifactId>InterestingFind-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>InterestingFind - Parent</name>
<modules>
<module>InterestingFind</module>
<module>InterestingFind-it</module>
</modules>
<properties>
<platform.version>4.1.1.4</platform.version>
<android-plugin>3.5.1</android-plugin>
<spring-android-version>1.0.1.RELEASE</spring-android-version>
<sign.keystore>${project.basedir}/my-release-key.keystore</sign.keystore>
<sign.alias>
</sign.alias>
<sign.storepass>
</sign.storepass>
<sing.keypass>
</sing.keypass>
</properties>
<repositories>
<repository>
<id>codehaus-snapshots</id>
<url>http://snapshots.repository.codehaus.org</url>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android-test</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
<!-- Androlog is a logging and reporting library for Android -->
<dependency>
<groupId>de.akquinet.android.androlog</groupId>
<artifactId>androlog</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.5.1</version>
<inherited>true</inherited>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
<sdk>
<platform>15</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.2</version>
<inherited>true</inherited>
<configuration>
<removeExistingSignatures>true</removeExistingSignatures>
<archiveDirectory />
<archive>${project.build.directory}/${project.build.finalName}.${project.packaging}</archive>
<verbose>true</verbose>
<certs>true</certs>
<keystore>${sign.keystore}</keystore>
<alias>${sign.alias}</alias>
<storepass>${sign.storepass}</storepass>
<keypass>${sign.keypass}</keypass>
</configuration>
</plugin>
<plugin>
<groupId>com.pyx4me</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.4</version>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard</artifactId>
<version>4.4</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<configuration>
<proguardVersion>4.4</proguardVersion>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>release</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>${android-plugin}</version>
<configuration>
<release>true</release>
</configuration>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-signing-properties</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>sign.keystore</property>
<message>The 'sign.keystore' property is missing. It must
contain the path to the
keystore used to sign the
application.
</message>
</requireProperty>
<requireFilesExist>
<files>
<file>${sign.keystore}</file>
</files>
<message>The 'sign.keystore' property does not point to a
file. It must contain the
path to the keystore used to sign
the application.
</message>
</requireFilesExist>
<requireProperty>
<property>sign.alias</property>
<message>The 'sign.alias' property is missing. It must
contain the key alias used to
sign the application.
</message>
</requireProperty>
<requireProperty>
<property>sign.storepass</property>
<message>The 'sign.storepass' property is missing. It must
contain the password of
the keystore used to sign the
application.
</message>
</requireProperty>
<requireProperty>
<property>sign.keypass</property>
<message>The 'sign.keypass' property is missing. It must
contain the password of the
key used to sign the application.
</message>
</requireProperty>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>linux</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<properties>
<rt.jar.path>${java.home}/jre/lib/rt.jar</rt.jar.path>
<jsse.jar.path>${java.home}/jre/lib/jsse.jar</jsse.jar.path>
</properties>
</profile>
<!-- mac profile has to be after unix since running on mac will trigger
both -->
<profile>
<id>mac</id>
<activation>
<os>
<family>mac</family>
</os>
</activation>
<properties>
<!-- absolute path -->
<!--<rt.jar.path>/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/classes.jar</rt.jar.path> -->
<!-- or with JAVA_HOME /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/ -->
<rt.jar.path>${java.home}/../Classes/classes.jar</rt.jar.path>
<jsse.jar.path>${java.home}/../Classes/jsse.jar</jsse.jar.path>
</properties>
</profile>
<profile>
<id>windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<rt.jar.path>${java.home}/jre/lib/rt.jar</rt.jar.path>
<jsse.jar.path>${java.home}/jre/lib/jsse.jar</jsse.jar.path>
</properties>
</profile>
</profiles>
Edit : updated pom.
Edit : uploaded Log file
Well... In your maven-processor-plugin configuration you're using the old package naming for the AA processor (ie : com.googlecode.androidannotations.AndroidAnnotationProcessor).
As you're using the 3.0-SNAPSHOT, you should modify it to use the new one : org.androidannotations.AndroidAnnotationProcessor
Also, I'm not sure you really need this plugin to make AA works.
Seems the problem was caused by a dependency not being resolved.
At first Maven did not even report this missing dependency, until I started removing things from my pom which I had added in an attempt to resolve this issue.
Now, what explains that the dependency didn't get auto-resolved, is the fact that there is no such artifact on the central maven repository.
As such, I added the following repository :
<repositories>
<!-- For developing with Android ROME Feed Reader -->
<repository>
<id>android-rome-feed-reader-repository</id>
<name>Android ROME Feed Reader Repository</name>
<url>https://android-rome-feed-reader.googlecode.com/svn/maven2/releases</url>
</repository>
</repositories>
Resulting in that 'hidden' dependency being resolved.
This dependency seems to be needed by the
<!-- Needed for androidannotations REST interface-->
<dependency>
<groupId>org.springframework.android</groupId>
<artifactId>spring-android-rest-template</artifactId>
<version>${spring-android-version}</version>
</dependency>
Spring docs report that this 'hidden dependency' of which we're speaking is needed for RSS and Atom feed support by the rest-template.
What made this even weirder is that the initial activity annotated by AA got created and resolved nicely. As long as I didn't refer to a generated class, e.g. for navigation, then it did compile and run.
From the moment I tried to use a class_ in code however, it went down this path.
Hope this helps !
Related
Since update to Luna, xml modification are not recognized in R-references in the Activity anymore (for example by using findViewById). Is this somewhere a bug or did I miss some Eclipse configuration.
To see R-references in the Activity, I always have to Maven build the project and execute Project->Clean then. This is very annoying. Any ideas where this problem is related to?
(Build Automatically is checked in Eclipse Project settings)
These is the installed software with their versions:
This is my example pom for the current project:
<?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.mycompany</groupId>
<artifactId>mygame</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>My Game</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<platform.version>4.4.2</platform.version>
<android.version>19</android.version>
<android.plugin.version>3.9.0-rc.2</android.plugin.version>
<java.version>1.6</java.version>
<android.sdk.path>/opt/android-sdk-linux</android.sdk.path>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<mockito.version>1.9.5</mockito.version>
<jackson.version>1.9.13</jackson.version>
<junit.version>4.8.2</junit.version>
<hamcrest.version>1.3</hamcrest.version>
<annotations.version>4.1.1.4</annotations.version>
<supportv4.version>r13</supportv4.version>
</properties>
<dependencies>
<!-- LInt Annotations -->
<dependency>
<groupId>com.google.android</groupId>
<artifactId>annotations</artifactId>
<version>${annotations.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- Non Android Tests --><!-- hamcrest must be before JUnit due to build errors -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.5.1</version>
<scope>test</scope>
</dependency>
<!-- JUnit has to be before Android, otherwise powermock causes a runtimeexception
"at junit.runner.version.id" -->
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>${supportv4.version}</version>
</dependency>
<dependency>
<groupId>com.nineoldandroids</groupId>
<artifactId>library</artifactId>
<version>2.4.0</version>
</dependency>
</dependencies>
<build>
<outputDirectory>target/classes</outputDirectory>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<plugins>
<plugin>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.2</version>
<configuration>
<finalName>${project.artifactId}-${project.version}</finalName>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>${android.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
<genDirectory>${project.basedir}/gen</genDirectory>
<sdk>
<platform>${android.version}</platform>
<path>${android.sdk.path}</path>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
<sign>
<debug>${debug}</debug>
</sign>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<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.9.0-rc.2,)</versionRange>
<goals>
<goal>generate-sources</goal>
<goal>proguard</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>devel</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<debug>true</debug>
</properties>
</profile>
<!-- release untested yet -->
<profile>
<id>release</id>
<properties>
<debug>false</debug>
</properties>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>signing</id>
<goals>
<goal>sign</goal>
</goals>
<phase>package</phase>
<inherited>true</inherited>
<configuration>
<archiveDirectory></archiveDirectory>
<includes>
<include>target/${project.artifactId}-${project.version}.apk</include>
</includes>
<keystore>path/to/keystore</keystore>
<storepass>storepasword</storepass>
<keypass>keypassword</keypass>
<alias>key-alias</alias>
<arguments>
<argument>-sigalg</argument>
<argument>MD5withRSA</argument>
<argument>-digestalg</argument>
<argument>SHA1</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<zipalign>
<verbose>true</verbose>
<skip>false</skip>
<inputApk>${project.build.directory}/${project.artifactId}-${project.version}.apk</inputApk>
<outputApk>${project.build.directory}/${project.artifactId}-${project.version}-RELEASE.apk</outputApk>
</zipalign>
</configuration>
<executions>
<execution>
<id>zipalign</id>
<phase>install</phase>
<goals>
<goal>zipalign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
I think my other problem with Lint is related to this problem too.
I have a several android library projects that I'm trying to convert to Maven.
I encountered a problem where mvn clean install is successful but in Eclipse there are import issues as if the classes in the project2 apklib is not in the classpath of project1.
First project POM.xml
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>android-clientsdk</artifactId>
<packaging>apklib</packaging>
<parent>
<groupId>com.company.client</groupId>
<artifactId>company-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<sdk>
<path>${android.sdk.path}</path>
<platform>${android.sdk.platform}</platform>
</sdk>
<!-- <deleteConflictingFiles>true</deleteConflictingFiles> -->
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<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.7.0,)</versionRange>
<goals>
<goal>generate-sources</goal>
<goal>consume-aar</goal>
<goal>proguard</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[2.1,)</versionRange>
<goals>
<goal>copy-dependencies</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>android-clientelement</artifactId>
<packaging>apklib</packaging>
<parent>
<groupId>com.company.client</groupId>
<artifactId>company-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<sdk>
<path>${android.sdk.path}</path>
<platform>${android.sdk.platform}</platform>
</sdk>
<!-- <deleteConflictingFiles>true</deleteConflictingFiles> -->
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<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.7.0,)</versionRange>
<goals>
<goal>generate-sources</goal>
<goal>consume-aar</goal>
<goal>proguard</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[2.1,)</versionRange>
<goals>
<goal>copy-dependencies</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.company.client</groupId>
<artifactId>android-clientsdk</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>
Technical's:
I'm using Eclipse Kepler.
I'm using the latest Android Configurator for M2E (Taken from the eclipse marketplace)
My question:
When depending on apklib should we see any evidence for this dependencies in Eclipse (like .class that are compiled from this library)?
Why Eclipse can't find the import from the packages in the depended apklib?
You must import your APKlib in your Eclipse workspace and then link it to your main application project (Project properties > Android > Add library and choose your APKLib project)
Sometimes, if you perform a clean or an update of your maven project, Eclipse loses the link of your apklib and you must add it again..
We're using Android Annotations, Cobertura, and maven. Cobertura is pulling in the _ classes for unit test coverage. How can we exclude them?
I tried adding the following to my pom but it only worked halfway. The classes no longer show in the report but line and branch coverage for that package shows <5% when the coverage for the base classes in that package are at 100%.
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.hps.prosper.android</groupId>
<artifactId>TabletCore</artifactId>
<version>0.2.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>Prosper-TabletCore</name>
<properties>
<stomp.version>0.2.0-SNAPSHOT</stomp.version>
<java.version>1.6</java.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.10</version>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.pivotallabs</groupId>
<artifactId>robolectric</artifactId>
<version>1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.googlecode.androidannotations</groupId>
<artifactId>androidannotations</artifactId>
<version>2.7.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.googlecode.androidannotations</groupId>
<artifactId>androidannotations-api</artifactId>
<version>2.7.1</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<resources>
<!-- filter manifest and put filtered file in target/filtered-manifest/ -->
<resource>
<directory>${project.basedir}</directory>
<targetPath>${project.build.directory}</targetPath>
<includes>
<include>AndroidManifest.xml</include>
<include>res/**/*</include>
</includes>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<instrumentation>
<ignores>
<ignore>com.hps.prosper.android.tabletcore.library.entity.*</ignore>
<ignore>com.hps.prosper.android.tabletcore</ignore>
<ignore>com.hps.prosper.android.contexts.*</ignore> </ignores>
<excludes>
<exclude>com/hps/prosper/android/tabletcore/library/entity/**/*.class</exclude>
<ignore>com/hps/prosper/android/tabletcore/*.class</ignore>
</excludes>
</instrumentation>
</configuration>
<executions>
<execution>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.5.0</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<run>
<debug>true</debug>
</run>
<sdk>
<platform>12</platform>
</sdk>
<emulator>
<avd>16</avd>
</emulator>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
I'm generating coverage reports at the command line:
mvn clean test -Ucobertura:cobertura
We also use Jenkins, but I'm just interested in the local reports for now. Once those are working right I'll test it on our build server and enlist some local gurus if needed.
If it's not possible, how can I add the source folder for the _ classes so I can at least click through and see where the holes are?
This is a duplicate of this question, but that answer does not solve my problem.
Some background to my specific build environment:
I am using the Android maven plugin along with this sample project. The project consists of a parent pom.xml, and then a pom.xml for each of the three sub modules (projects). each sub module defines the parent as the parent.
When I run mvn clean install on the raw downloaded project it builds and installs/runs on the phone fine.
But I have no added the source into Eclipse where it runs fine to have the mvn build script no longer work (i.e. the apk is smaller and missing classes).
Any ideas on how I could fix this would be greatly appreciated.
Here is the POM file for the parent and after that the POM for the app project. Sorry to be posting such large chunks of code but I'm not sure where the problem is.
Update For people facing a similar problem I have started a conversion on the Google Group [Maven Android Developers] located here. I may get an answer there first.
<?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.simpligility.android.morse</groupId>
<artifactId>morseflash-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>MorseFlash - Parent</name>
<properties>
<server_schema>http</server_schema>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android-test</artifactId>
<version>2.3.1</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.2</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<sdk>
<platform>10</platform>
</sdk>
<emulator>
<avd>23</avd>
<wait>10000</wait>
<!--<options>-no-skin</options> -->
</emulator>
<zipalign>
<verbose>true</verbose>
</zipalign>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.5</version>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<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.2.0,)</versionRange>
<goals>
<goal>manifest-update</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<!-- the standard profile runs the instrumentation tests -->
<id>standard</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>
<module>morse-lib</module>
<module>morseflash-app</module>
<module>morseflash-instrumentation</module>
</modules>
<properties>
<!-- when i will try to enter this address the app will start :) -->
<!-- for development i want to use my local host -->
<!-- server schema is defined globally for all profiles but can be overridden
here for the local profile -->
<!-- this properties are good for all the maven modules -->
<server_host>192.168.1.12</server_host>
<server_path></server_path>
</properties>
</profile>
<profile>
<!-- the release profile does sign, proguard, zipalign ... but does not
run instrumentation tests -->
<id>release</id>
<!-- via this activation the profile is automatically used when the release
is done with the maven release plugin -->
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<modules>
<module>morse-lib</module>
<module>morseflash-app</module>
</modules>
<properties>
<!-- when i will try to enter this address the app will start :) -->
<!-- for release i want to use my git -->
<!-- server schema is defined globally for all profiles but can be overridden
here for the local profile -->
<!-- this properties are good for all the maven modules -->
<server_host>github.com</server_host>
<server_path>/jayway/maven-android-plugin-samples</server_path>
</properties>
</profile>
</profiles>
</project>
Now for app project:
<?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>
<parent>
<groupId>com.simpligility.android.morse</groupId>
<artifactId>morseflash-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>morseflash-app</artifactId>
<packaging>apk</packaging>
<name>MorseFlash - App</name>
<properties>
<environment>development</environment>
</properties>
<dependencies>
<dependency>
<groupId>com.simpligility.android.morse</groupId>
<artifactId>morse-library</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android-test</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<!-- <sourceDirectory>src</sourceDirectory> -->
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<!-- use the copy resources instead of resources, which adds it to
the eclipse buildpath -->
<phase>initialize</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/res</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/templates/res</directory>
<targetPath>${project.basedir}/res</targetPath>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<manifest>
<debuggable>true</debuggable>
</manifest>
</configuration>
<executions>
<execution>
<id>manifestUpdate</id>
<phase>process-resources</phase>
<goals>
<goal>manifest-update</goal>
</goals>
</execution>
<execution>
<id>alignApk</id>
<phase>package</phase>
<goals>
<goal>zipalign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>development</id>
<!-- using this since activeByDefault does not work well with multiple
profiles -->
<activation>
<property>
<name>environment</name>
<value>!production</value>
</property>
</activation>
<properties>
<deployment.stage>In Development</deployment.stage>
</properties>
</profile>
<profile>
<id>production</id>
<properties>
<deployment.stage>In Production</deployment.stage>
</properties>
</profile>
<profile>
<id>release</id>
<!-- via this activation the profile is automatically used when the release
is done with the maven release plugin -->
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<executions>
<execution>
<id>signing</id>
<goals>
<goal>sign</goal>
<goal>verify</goal>
</goals>
<phase>package</phase>
<inherited>true</inherited>
<configuration>
<removeExistingSignatures>true</removeExistingSignatures>
<archiveDirectory />
<includes>
<include>${project.build.directory}/${project.artifactId}.apk</include>
</includes>
<keystore>${sign.keystore}</keystore>
<alias>${sign.alias}</alias>
<storepass>${sign.storepass}</storepass>
<keypass>${sign.keypass}</keypass>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
<!-- the signed apk then needs to be zipaligned and we activate proguard
and we run the manifest update -->
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<sign>
<debug>false</debug>
</sign>
<zipalign>
<skip>false</skip>
<verbose>true</verbose>
<inputApk>${project.build.directory}/${project.artifactId}.apk</inputApk>
<outputApk>${project.build.directory}/${project.artifactId}-signed-aligned.apk
</outputApk>
</zipalign>
<manifest>
<debuggable>false</debuggable>
<versionCodeAutoIncrement>true</versionCodeAutoIncrement>
</manifest>
<proguard>
<skip>false</skip>
</proguard>
</configuration>
<executions>
<execution>
<id>manifestUpdate</id>
<phase>process-resources</phase>
<goals>
<goal>manifest-update</goal>
</goals>
</execution>
<execution>
<id>alignApk</id>
<phase>package</phase>
<goals>
<goal>zipalign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/${project.artifactId}-signed-aligned.apk</file>
<type>apk</type>
<classifier>signed-aligned</classifier>
</artifact>
<artifact>
<file>${project.build.directory}/proguard/mapping.txt</file>
<type>map</type>
<classifier>release</classifier>
</artifact>
</artifacts>
</configuration>
<executions>
<execution>
<id>attach-signed-aligned</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
So it turns out I just upset the project structure when manually setting up the projects in Eclipse. It was juts by chance that a colleague mentioned the mvn eclipse:eclipse command, which sorted out all my issues.
With reference to this sample project. I did the following to get everything working in Eclipse and Maven.
cd into each project { morse-lib, morseflash-app, morseflash-instrumentation } and run mvn eclipse:eclipse.
In Eclipse import each project individually.
Not *-app and *-instrumentation are Android projects and *-lib is a
Java project. All projects should be set to Java compiler 1.6.
For each project in Eclipse Right Click -> Configure -> Convert To Maven
For projects { *-app, *-instrumentation }, target/generated-sources/r -> right click -> properties -> resources -> resource filters -> add group -> { exclude all, files and folders, all children(recursive) }
Clean all projects then build all
You should now be able to run the morseflash-app project as an Android application.
From the command line in the morseflash folder (contains *-lib, *-app, *-instrumentation) you should be able to execure mvn clean install android:deploy to get the app on the phone.
Hope this helps somebody else out. Ping me if not.
Try upgrading to 3.5, that i would suggest you to go with. I would also specify the source and target to the language level.I was once facing such issue, when my eclipse was configured to different version altogether.
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<sdk>
<platform>10</platform>
</sdk>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
<emulator>
<avd>23</avd>
<wait>10000</wait>
<!--<options>-no-skin</options> -->
</emulator>
<zipalign>
<verbose>true</verbose>
</zipalign>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
</plugin>
I've developing application using AndroidAnnotations and want to use Robolectric for unit testing.
I can't get it working though.
Application and tests are placed in single project.
Source is placed under /src/main/java and test under /src/test/java. Both folders are source folders.
When running test from Eclipse using Eclipse JUnit launcher I get:
Class not found org.demoapp.MyActivityTest
java.lang.ClassNotFoundException: org.demoapp.MyActivityTest
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
When running from commandline mvn clean test I get:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project demo-app: Compilation failure:
[ERROR] \demo-app\src\test\java\org\demoapp\MyActivityTest.java:[3,16] package org.junit does not exist
[ERROR] \demo-app\src\test\java\org\demoapp\MyActivityTest.java:[4,23] package org.junit.runner does not exist
[ERROR] \demo-app\src\test\java\org\demoapp\MyActivityTest.java:[6,33] package com.xtremelabs.robolectric does not exist
[ERROR] \demo-app\src\test\java\org\demoapp\MyActivityTest.java:[8,1] cannot find symbol
[ERROR] symbol: class RunWith
...
...
Although all classes compiles in eclipse.
Actually I don't know what's the problem here. Where should I start?
<?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>org.demoapp</groupId>
<artifactId>demo-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>Demo :: App</name>
<properties>
<environment>development</environment>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.libphonenumber</groupId>
<artifactId>libphonenumber</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.androidannotations</groupId>
<artifactId>androidannotations</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.androidannotations</groupId>
<artifactId>androidannotations</artifactId>
<classifier>api</classifier>
</dependency>
<dependency>
<groupId>com.pivotallabs</groupId>
<artifactId>robolectric</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.3.0</version>
<extensions>true</extensions>
<configuration>
<manifest>
<debuggable>true</debuggable>
</manifest>
</configuration>
<executions>
<execution>
<id>manifestUpdate</id>
<phase>process-resources</phase>
<goals>
<goal>manifest-update</goal>
</goals>
</execution>
<execution>
<id>alignApk</id>
<phase>package</phase>
<goals>
<goal>zipalign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
<plugin>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.2</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.5</version>
</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.2.0,)</versionRange>
<goals>
<goal>manifest-update</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>development</id>
<activation>
<property>
<name>environment</name>
<value>!production</value>
</property>
</activation>
<properties>
<deployment.stage>In Development</deployment.stage>
</properties>
</profile>
<profile>
<id>production</id>
<properties>
<deployment.stage>In Production</deployment.stage>
</properties>
</profile>
<profile>
<id>release</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<executions>
<execution>
<id>signing</id>
<goals>
<goal>sign</goal>
<goal>verify</goal>
</goals>
<phase>package</phase>
<inherited>true</inherited>
<configuration>
<removeExistingSignatures>true</removeExistingSignatures>
<archiveDirectory />
<includes>
<include>${project.build.directory}/${project.artifactId}.apk</include>
</includes>
<keystore>keystore/keys.keystore</keystore>
<alias>alias</alias>
<storepass>${sign.storepass}</storepass>
<keypass>${sign.keypass}</keypass>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.3.0</version>
<inherited>true</inherited>
<configuration>
<sign>
<debug>false</debug>
</sign>
<zipalign>
<verbose>true</verbose>
<inputApk>${project.build.directory}/${project.artifactId}.apk</inputApk>
<outputApk>${project.build.directory}/${project.artifactId}-signed-aligned.apk
</outputApk>
</zipalign>
<manifest>
<debuggable>false</debuggable>
<versionName>${project.version}</versionName>
<versionCodeAutoIncrement>true</versionCodeAutoIncrement>
</manifest>
<proguard>
<skip>true</skip>
</proguard>
</configuration>
<executions>
<execution>
<id>manifestUpdate</id>
<phase>process-resources</phase>
<goals>
<goal>manifest-update</goal>
</goals>
</execution>
<execution>
<id>alignApk</id>
<phase>package</phase>
<goals>
<goal>zipalign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>com.googlecode.libphonenumber</groupId>
<artifactId>libphonenumber</artifactId>
<version>5.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.googlecode.androidannotations</groupId>
<artifactId>androidannotations</artifactId>
<version>2.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.googlecode.androidannotations</groupId>
<artifactId>androidannotations</artifactId>
<classifier>api</classifier>
<version>2.6</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
In your pom.xml, you set the source directory to src, but you say that your sources are in src/main/java folder and you tests in src/test/java.
Could you try to remove the <sourceDirectory>src</sourceDirectory>, so Maven use this default file structure ?
Also, for now, I have never been able to launch unit test with robolectric from Eclipse... But it works with maven.