Core libraries with android maven plugin - android

I want to use nativ libraries with android. When i try to complie my project with
mvn clean install
I get an error
[INFO] If you really intend to build a core library -- which is only
[INFO] appropriate as part of creating a full virtual machine
[INFO] distribution, as opposed to compiling an application -- then use
[INFO] the "--core-library" option to suppress this error message.
How to add --core-library param to pom.xml ?
My pom looks like
http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
<parent>
<groupId>com.temp</groupId>
<artifactId>SipAndroidClient</artifactId>
<version>0.1</version>
</parent>
<artifactId>android-di</artifactId>
<packaging>apk</packaging>
<name>android-di - Application</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.pivotallabs</groupId>
<artifactId>robolectric</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
</dependency>
<dependency>
<groupId>org.roboguice</groupId>
<artifactId>roboguice</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>de.mindpipe.android</groupId>
<artifactId>android-logging-log4j</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>javax.sip</groupId>
<artifactId>jain-sip-api</artifactId>
<version>1.2.1.4</version>
</dependency>
<dependency>
<groupId>javax.sip</groupId>
<artifactId>jain-sip-ri</artifactId>
<version>1.2.167</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<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>10</platform>
<path>/home/damian/.android-sdk</path>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>

I believe this is what you are looking for http://maven-android-plugin-m2site.googlecode.com/svn/dex-mojo.html
Have a look at the dex section, setting CoreLibrary to true will send "--core-library" to dex.

Related

Android DarkActionBar theme not found parent with maven

Im try to do a maven android proyect.
I have this in style.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"></style>
and this error
error: Error retrieving parent for item: No resource found that matches the given name
'Theme.AppCompat.Light.DarkActionBar'.
I have this in pom.xml
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Plugins -->
<android-maven-plugin.version>3.8.2</android-maven-plugin.version>
<maven-compiler-plugin.version>2.3.2</maven-compiler-plugin.version>
<api.platform>16</api.platform>
<eclipse-lifecycle-plugin.version>1.0.0</eclipse-lifecycle-plugin.version>
<!-- Compilation dependencies, build.gradle -->
<android-sdk.version>18</android-sdk.version>
<android-buildtools.version>18.1.1</android-buildtools.version>
<android-support.version>r7</android-support.version>
<!-- Dependencies -->
<androidannotations.version>3.0.1</androidannotations.version>
<android.version>4.4.2_r2</android.version>
<support-v4.version>r7</support-v4.version>
<spring-android-rest-template.version>1.0.1.RELEASE</spring-android-rest-template.version>
</properties>
<dependencies>
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
<version>${android.version}</version>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v4</artifactId>
<version>19.0.1</version>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v13</artifactId>
<version>19.0.1</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>19.0.1</version>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7</artifactId>
<version>19.0.1</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7-appcompat</artifactId>
<version>19.0.1</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7-appcompat</artifactId>
<version>19.0.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7</artifactId>
<version>19.0.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.androidannotations</groupId>
<artifactId>androidannotations</artifactId>
<version>${androidannotations.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.androidannotations</groupId>
<artifactId>androidannotations</artifactId>
<version>${androidannotations.version}</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>${support-v4.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.android</groupId>
<artifactId>spring-android-rest-template</artifactId>
<version>${spring-android-rest-template.version}</version>
</dependency>
<dependency>
<groupId>pl.charmas.android</groupId>
<artifactId>android-reactive-location</artifactId>
<version>0.1</version>
<type>aar</type>
</dependency>
<dependency>
<groupId>com.google.android.gms</groupId>
<artifactId>play-services</artifactId>
<version>4.1.32</version>
<type>aar</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>${android-maven-plugin.version}</version>
<configuration>
<nativeLibrariesDirectory>ignored</nativeLibrariesDirectory>
<sdk>
<platform>${android-sdk.version}</platform>
</sdk>
<undeployBeforeDeploy>false</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>${eclipse-lifecycle-plugin.version}</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>enforce</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<versionRange>[1.4.0,)</versionRange>
<goals>
<goal>replace</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
And this error in pom.xml
dependency=[android.support:compatibility-v7:apklib:19.0.1:compile] not found in
workspace
In my maven dependecencies there are
compat-v4,v13, support-v4 compat-v7-appcompat, compat-v7 ...
Whats wrong?

maven android plugin with error ( dependency=[android.support:compatibility-v7:apklib:19:compile] not found )

I am using maven 3.1.1. with Eclipse Kepler installed with Android-Configurator-for-M2E.
My POM.XML looks like:
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company.sample</groupId>
<artifactId>SampleApplication</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>apk</packaging>
<name>SampleApplication</name>
<description>A sample application to demo clean android code.</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<platform.version>2.3.1</platform.version>
<android.plugin.version>3.6.0</android.plugin.version>
</properties>
<dependencies>
<!-- android SDK -->
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.3.1</version>
<scope>provided</scope>
</dependency>
<!-- support-v4 -->
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-v4</artifactId>
<version>19.0.0</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- v7-extra -->
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7</artifactId>
<version>19</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7</artifactId>
<version>19</version>
<type>jar</type>
</dependency>
<!-- v7-appcompat -->
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7-appcompat</artifactId>
<version>19</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7-appcompat</artifactId>
<version>19</version>
<type>jar</type>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.6.0</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<platform>18</platform>
</sdk>
<action>
<ignore></ignore>
</action>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<path>${env.ANDROID_HOME}</path>
<platform>18</platform>
</sdk>
<deleteConflictingFiles>true</deleteConflictingFiles>
</configuration>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>allow-snapshots</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</project>
The command: mvn clean install, builds successfully, but refreshing the project in eclipse gives this error:
dependency=[android.support:compatibility-v7:apklib:19:compile] not found in workspace pom.xml /SampleApplication line 1 me.gladwell.eclipse.m2e.android.markers.dependency.apklib
Fixed this problem by downloading a new copy of eclipse 4.3.1 and re-installed the following:
ADT pluugin
M2E
M2E-Android
Then imported the same project which built fine with: mvn clean install.
Then removed all the Libraries from the build path and did: Android-Tools>Fix Project Properties.

Android Tests Compiling using Maven

I have been bashing my head against this for days now so I thought its time to ask.
I have an android project and a android-test project. I can run my tests in eclipse and it all works great.
So now I am moving on to use these tests through maven so I can use them for CI.
Anyway long story short I can't get maven to compile/run them. I have looked at all the examples provided with the android-maven-plugin to no avail.
Main POM.
<groupId>com.xxx.x_android_finder</groupId>
<artifactId>x_Android_Finder</artifactId>
<version>1.0.2</version>
<packaging>apk</packaging>
<name>xxxx</name>
<dependencies>
<!-- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency> -->
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.0.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android.maps</groupId>
<artifactId>maps</artifactId>
<version>15_r2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>library</artifactId>
<version>4.1.0</version>
<type>apklib</type>
<exclusions>
<exclusion>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>plugin-maps</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>net.hockeyapp.android</groupId>
<artifactId>HockeySDK</artifactId>
<version>2.0.2</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.codeslap</groupId>
<artifactId>android-facebook</artifactId>
<version>1.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[3.0,)</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jakewharton</id>
<url>http://r.jakewharton.com/maven/release/</url>
</repository>
<repository>
<id>codeslap</id>
<url>http://casidiablo.github.com/codeslap-maven/repository/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.2.0</version>
<extensions>true</extensions>
<configuration>
<!-- replace resources with target specific -->
<renameManifestPackage>${customerPackage}</renameManifestPackage>
<resourceOverlayDirectory>${customerResources}</resourceOverlayDirectory>
<sign>
<debug>false</debug>
</sign>
<manifest>
<versionCodeAutoIncrement>true</versionCodeAutoIncrement>
</manifest>
<zipalign>
<inputApk>${project.build.directory}/${project.build.finalName}.apk</inputApk>
<outputApk>${project.build.directory}/x_Android_Finder.apk</outputApk>
</zipalign>
<proguard>
<skip>true</skip>
</proguard>
<sdk>
<!-- platform or api level (api level 4 = platform 1.6)-->
<platform>17</platform>
</sdk>
<assetsDirectory>${project.basedir}/${customerAssets}</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
</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.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/*.apk</include>
</includes>
<keystore>../certificates/xxx.keystore</keystore>
<storepass>xxxx</storepass>
<keypass>xxxx</keypass>
<alias>csl</alias>
</configuration>
</execution>
</executions>
</plugin>
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin> -->
</plugins>
</build>
Test pom
<artifactId>x_Android_Finder_Test</artifactId>
<packaging>apk</packaging>
<version>1.0.0</version>
<name>xxxxx</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android-test</artifactId>
<version>1.5_r3</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.0.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android.maps</groupId>
<artifactId>maps</artifactId>
<version>15_r2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>library</artifactId>
<version>4.1.0</version>
<type>apklib</type>
<exclusions>
<exclusion>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>plugin-maps</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>com.connectionservices.csl_android_finder</groupId>
<artifactId>Csl_Android_Finder</artifactId>
<type>apk</type>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>com.connectionservices.csl_android_finder</groupId>
<artifactId>Csl_Android_Finder</artifactId>
<scope>provided</scope>
<type>jar</type>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.hockeyapp.android</groupId>
<artifactId>HockeySDK</artifactId>
<version>2.0.2</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.codeslap</groupId>
<artifactId>android-facebook</artifactId>
<version>1.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[3.0,)</version>
</dependency>
<dependency>
<groupId>com.jayway.android.robotium</groupId>
<artifactId>robotium-solo</artifactId>
<version>3.6</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>oss.sonatype.org-jayway-with-staging</id>
<url>http://oss.sonatype.org/content/groups/jayway-with-staging/</url>
</repository>
<repository>
<id>jakewharton</id>
<url>http://r.jakewharton.com/maven/release/</url>
</repository>
<repository>
<id>codeslap</id>
<url>http://casidiablo.github.com/codeslap-maven/repository/</url>
</repository>
</repositories>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<platform>15</platform>
</sdk>
<test>
<createReport>true</createReport>
</test>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.13</version>
</plugin>
<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>
<removeExistingSignatures>true</removeExistingSignatures>
<archiveDirectory></archiveDirectory>
<includes>
<include>target/*.apk</include>
</includes>
<keystore>../certificates/xxxx.keystore</keystore>
<storepass>xxx</storepass>
<keypass>xxxx</keypass>
<alias>csl</alias>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
the test projects are held under main/java/... in the test project
When I compile i use mvn clean test
the errors its throwing up are
ERROR] /Users/aidenfry/AndroidHSF(trunknew)/x_Android_Finder_Parent/x_Android_Finder_Test/src/main/java/com/xxxxxxx/x_android_finder_test/FinderActivityTest.java:[27,7] cannot access junit.framework.TestCase
[ERROR] class file for junit.framework.TestCase not found
[ERROR] public class FinderActivityTest extends ActivityInstrumentationTestCase2<FinderActivity> {
[ERROR] /Users/aidenfry/AndroidHSF(trunknew)/x_Android_Finder_Parent/x_Android_Finder_Test/src/main/java/com/xxxx/xx_android_finder_test/FinderActivityTest.java:[39,8] cannot find symbol
[ERROR] symbol : variable super
[ERROR] location: class
I can provide more but they are all similar to this, seems it cant find the Junit lib? But i already have that in the dependancioes.
If anyone can help/hints for me to sort out this mess It would be very much appreciated!
In case someone has the same issue, and wants to execute real Android Unit Tests instead of normal JUnit Tests:
You need to uncomment
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<!-- scope is compile, not test! -->
<scope>compile</scope>
</dependency>
the junit dependency and use normal scope (compile), not test!
Hope that helps.
Ok, so here is how i did it.
I originally had my test cases in a seperate module / eclipse project. This seemed to be buggering up my stuff.
Moved the class into the main application project under src/main/test this now fixed all my issues thanks!

Android maven install fails with external project

This is my projects POM.XML file
<?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.mycomp</groupId>
<artifactId>abc</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>xyx</name>
<dependencies>
<dependency>
<groupId>org.springframework.android</groupId>
<artifactId>spring-android-rest-template</artifactId>
<version>1.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.8</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>20030203.000129</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>actionbarsherlock</artifactId>
<version>4.2.0</version>
<type>apklib</type>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src/main/java</sourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.1.1</version>
<extensions>true</extensions>
</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>
Now in my Android project i have added an external project, that is not maven based. now when i execute mvn3 install i get a
Failed to execute goal
com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1:generate-sources
(default-generate-sources) MojoExecutionException: ANDROID-040-001: Could not execute: Command = /bin/sh -c etc.
Now i run the above command in my command line and its complaining that the it cannot find attributes belonging to my external project. What can i do ?

Building Android app and run Robotium tests with Maven

I really need your help here. I want to set up Jenkins to build my Android app and run my Robotium tests on emulator using Maven. I think I did everything ok but still have same error. Have you ever had something like that? My project structure is below:
izi-mobiler.xml
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pl.araneo.farmadroid</groupId>
<artifactId>izi-mobiler</artifactId>
<version>366</version>
<packaging>pom</packaging>
<name>IZI</name>
<modules>
<module>izi-mobiler-app</module>
<module>izi-mobiler-test</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.0.1.2</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android-test</artifactId>
<version>4.0.1.2</version>
</dependency>
<dependency>
<groupId>com.pivotallabs</groupId>
<artifactId>robolectric</artifactId>
<version>1.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-lgpl</artifactId>
<version>1.7.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>org.roboguice</groupId>
<artifactId>roboguice</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-multibindings</artifactId>
<version>3.0</version>
<exclusions>
<exclusion>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-assistedinject</artifactId>
<version>3.0</version>
<exclusions>
<exclusion>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r7</version>
</dependency>
<!-- Action Bar sherlock -->
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>library</artifactId>
<version>4.1.0</version>
<type>apklib</type>
</dependency>
<!-- Let Roboguice and Sherlock work together -->
<dependency>
<groupId>com.github.rtyley</groupId>
<artifactId>roboguice-sherlock</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.0.0-alpha-13</version>
<extensions>true</extensions>
<configuration>
<sdk>
<platform>15</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
izi-mobiler-app.xml
<?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>pl.araneo.farmadroid</groupId>
<artifactId>izi-mobiler</artifactId>
<version>366</version>
<relativePath>../</relativePath>
</parent>
<groupId>pl.araneo.farmadroid</groupId>
<artifactId>izi-mobiler-app</artifactId>
<version>366</version>
<packaging>apk</packaging>
<name>IZI - App</name>
<properties>
<platform.version>4.0.1.2</platform.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.pivotallabs</groupId>
<artifactId>robolectric</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-lgpl</artifactId>
<version>1.7.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>org.roboguice</groupId>
<artifactId>roboguice</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-multibindings</artifactId>
<exclusions>
<exclusion>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-assistedinject</artifactId>
<exclusions>
<exclusion>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
</dependency>
<!-- Action Bar sherlock -->
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>library</artifactId>
<type>apklib</type>
</dependency>
<!-- Let Roboguice and Sherlock work together -->
<dependency>
<groupId>com.github.rtyley</groupId>
<artifactId>roboguice-sherlock</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.4.0</version>
<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>
<extensions>true</extensions>
</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>
izi-mobiler-test.xml
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>pl.araneo.farmadroid</groupId>
<artifactId>izi-mobiler</artifactId>
<version>366</version>
</parent>
<groupId>pl.araneo.farmadroid</groupId>
<artifactId>izi-mobiler-test</artifactId>
<packaging>apk</packaging>
<name>IZI - Test</name>
<dependencies>
<dependency>
<groupId>com.jayway.android.robotium</groupId>
<artifactId>robotium-solo</artifactId>
<version>1.8.0</version>
</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>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
</dependency>
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>library</artifactId>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.github.rtyley</groupId>
<artifactId>roboguice-sherlock</artifactId>
</dependency>
<dependency>
<groupId>pl.araneo.farmadroid</groupId>
<artifactId>izi-mobiler-app</artifactId>
<version>366</version>
<type>apk</type>
</dependency>
<dependency>
<groupId>pl.araneo.farmadroid</groupId>
<artifactId>izi-mobiler-app</artifactId>
<version>366</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
Stack Trace
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/piotrslesarew/git/izi-mobiler/izi-mobiler-test/src/main/java/pl/araneo/farmadroid/ui/activities/test/DashboardViewTest.java:[7,7] error: cannot access TestCase
[ERROR] class file for junit.framework.TestCase not found
/home/piotrslesarew/git/izi-mobiler/izi-mobiler-test/src/main/java/pl/araneo/farmadroid/ui/activities/test/DashboardViewTest.java:[17,24] error: cannot find symbol
[ERROR] class DashboardViewTest
/home/piotrslesarew/git/izi-mobiler/izi-mobiler-test/src/main/java/pl/araneo/farmadroid/ui/activities/test/DashboardViewTest.java:[17,46] error: cannot find symbol
[ERROR] class DashboardViewTest
/home/piotrslesarew/git/izi-mobiler/izi-mobiler-test/src/main/java/pl/araneo/farmadroid/ui/activities/test/DashboardViewTest.java:[15,4] error: method does not override or implement a method from a supertype
[INFO] 4 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] IZI ............................................... SUCCESS [0.183s]
[INFO] IZI - App ......................................... SUCCESS [36.895s]
[INFO] IZI - Test ........................................ FAILURE [3.741s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 41.924s
[INFO] Finished at: Sat Nov 17 16:40:51 CET 2012
[INFO] Final Memory: 35M/354M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project izi-mobiler-test: Compilation failure: Compilation failure:
[ERROR] /home/piotrslesarew/git/izi-mobiler/izi-mobiler-test/src/main/java/pl/araneo/farmadroid/ui/activities/test/DashboardViewTest.java:[7,7] error: cannot access TestCase
[ERROR] class file for junit.framework.TestCase not found
[ERROR] /home/piotrslesarew/git/izi-mobiler/izi-mobiler-test/src/main/java/pl/araneo/farmadroid/ui/activities/test/DashboardViewTest.java:[17,24] error: cannot find symbol
[ERROR] class DashboardViewTest
[ERROR] /home/piotrslesarew/git/izi-mobiler/izi-mobiler-test/src/main/java/pl/araneo/farmadroid/ui/activities/test/DashboardViewTest.java:[17,46] error: cannot find symbol
[ERROR] class DashboardViewTest
[ERROR] /home/piotrslesarew/git/izi-mobiler/izi-mobiler-test/src/main/java/pl/araneo/farmadroid/ui/activities/test/DashboardViewTest.java:[15,4] error: method does not override or implement a method from a supertype
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :izi-mobiler-test
Since Instrumentation Tests are in their own module and should be in the 'src/main/java' directory and not in the 'src/main/test' they appear to be compiled in a different lifecycle phase than tests usually are.
I eliminated this particular error in my project by setting the junit scope from test to compile for the test module:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>compile</scope>
</dependency>
(After that my tests fail to run on the emulator)

Categories

Resources