Importing support library appcompat to Maven project - android

I converted my Android project into Maven project. I have support library called appcompat_v7, which I would like to add into my Maven dependencies.
I read that I should add dependencies to pom.xml
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7-appcompat</artifactId>
<version>19.1.0</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7-appcompat</artifactId>
<version>19.1.0</version>
<type>jar</type>
</dependency>
Also built jar and apklib by running:
mvn install:install-file -Dfile="./com/android/support/appcompat-v7/19.1.0/appcompat-v7-19.1.0.aar"/ -DpomFile="./com/android/support/appcompat-v7/19.1.0/appcompat-v7-19.1.0.pom"/ -Dpackaging="apklib"
mvn install:install-file -Dfile="./com/android/support/appcompat-v7/19.1.0/appcompat-v7-19.1.0.jar"/ -DpomFile="./com/android/support/appcompat-v7/19.1.0/appcompat-v7-19.1.0.pom"/ -Dpackaging="jar"
My pom.xml is now following:
<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>ProjectTest</groupId>
<artifactId>ProjectTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>19.1.0</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>19.1.0</version>
<type>jar</type>
</dependency>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source/>
<target/>
</configuration>
</plugin>
</plugins>
</build>
</project>
I am still having error ''R cannot be resolved to a variable'' after I deleted support libraby appcompat_v7

Related

Missing artifact com.google.android.google-play-services:google-play-services:jar: 1

I have created Android Project and then converted into Android-Maven Project. Then, I installed/downloaded required dependencies. However, after installing/downloading them, I am getting this error
Missing artifact
com.google.android.google-play-services:google-play-services:jar:1
I don't know whats going wrong here. I am posting my pom.xml below
<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>HelloWorld</groupId>
<artifactId>HelloWorld</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source/>
<target/>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>java.net</id>
<url>https://maven.java.net/content/repositories/public/</url>
</repository>
<repository>
<id>com.google.api</id>
<url>http://mvnrepository.com/artifact/com.google.http-client</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>.....</groupId>
<artifactId>.....</artifactId>
<version>...</version>
</dependency>
<dependency>
<groupId>.....</groupId>
<artifactId>.....</artifactId>
<version>...</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client-android</artifactId>
<version>1.12.0-beta</version>
</dependency>
</dependencies>
</project>
I am attaching screenshot for reference. I tried all the questions and answers which are related to this on SO but not getting it done.
Screenshot for reference:
I tried adding below code and some other SO ways but didn't work.
<dependency>
<groupId>com.google.android.gsm</groupId>
<artifactId>google-play-services</artifactId>
<version>3</version>
<type>apklib</type>
</dependency>

Android library project -exporting in jar format working in eclipse and ant but not in maven

I have a android library project . I create a jar . now I copied the jar to the libs folder in a android application and build apk using eclipse and ant . the apk file is working but when I try to build using maven the apk file is not working .I have this issue from long time.
Can you correct if I made any mistake in pom file.
pom file for android application :
<?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.project.servicefoundation</groupId>
<artifactId>projectservicefoundation</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>projectserviceFoundation</name>
<dependencies>
<dependency>
<groupId>com.project.servicefoundation</groupId>
<artifactId>androidsdk</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android-test</artifactId>
<version>2.3.1</version>
<scope>provided</scope>
</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.5.3</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<executions>
<execution>
<id>androidsdktests</id>
<phase>test</phase>
<goals>
<goal>
emulator-start
</goal>
<goal>
internal-integration-test
</goal>
</goals>
</execution>
</executions>
<configuration>
<sdk>
<!-- platform or api level (api level 4 = platform 1.6) -->
<platform>19</platform>
</sdk>
<emulator>
<avd>mydevice</avd>
<!-- Wait for emulator starting (3 minutes) -->
<wait>180000</wait>
<options>-no-skin</options>
</emulator>
</configuration>
</plugin>
</plugins>
</build>
</project>
pom file for the android library 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.project.servicefoundation</groupId>
<artifactId>androidsdk</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>AndroidSDK</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
The name of android library project is androidsdk.
You've declared your dependency to androidsdk as provided, which means it will not be included in your apk (which explains why it does not work) :
<dependency>
<groupId>com.project.servicefoundation</groupId>
<artifactId>androidsdk</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
Simply removing <scope>provided</scope> should do the trick.

Maven dependency scope for robolectric either stops tests running or makes build run out of heap space

I have this Android project and some difficulty configuring the build with Maven & Robolectric. If I set the scope of the robolectric dependency to 'test', then the project builds fine, but the tests fail to run [wrong version of junit or java.lang.NoClassDefFoundError]. If I don't set the scope of the robolectric dependency, the tests run fine (and pass) but the build runs out of heap space.
I'm new to Maven and am probably doing something wrong.
My dependencies look this ::
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.robolectric</groupId>
<artifactId>robolectric</artifactId>
<version>2.0-alpha-1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.j256.ormlite</groupId>
<artifactId>ormlite-android</artifactId>
<version>4.45</version>
</dependency>
<dependency>
<groupId>com.j256.ormlite</groupId>
<artifactId>ormlite-core</artifactId>
<version>4.45</version>
</dependency>
<dependency>
<groupId>com.j256.ormlite</groupId>
<artifactId>ormlite-jdbc</artifactId>
<version>4.45</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.robolectric</groupId>
<artifactId>robolectric</artifactId>
<version>2.0-rc2</version>
<scope>test</scope>
</dependency>
</dependencies>
Any wisdom on what's going on here will be gratefully received and put to immediate good use :)
Here's the complete pom.xml after updating with Matt's advice. (below) Unfortunately the issue persists.
<?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.odl</groupId>
<artifactId>GhostRunner</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>GhostRunner</name>
<properties>
<platform.version> 2.3.3 </platform.version>
<android.sdk.path>/Users/chrisdanson/Development/android-sdk-macosx</android.sdk.path>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.robolectric</groupId>
<artifactId>robolectric</artifactId>
<version>2.1</version>
<!--<scope>test</scope>-->
</dependency>
<dependency>
<groupId>com.j256.ormlite</groupId>
<artifactId>ormlite-android</artifactId>
<version>4.45</version>
</dependency>
<dependency>
<groupId>com.j256.ormlite</groupId>
<artifactId>ormlite-core</artifactId>
<version>4.45</version>
</dependency>
<dependency>
<groupId>com.j256.ormlite</groupId>
<artifactId>ormlite-jdbc</artifactId>
<version>4.45</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.1.1</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>10</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
So .. having updated the plugin dependency versions and run a mvn 'clean' & 'install' as well the problem is still present. Running a robolectric test gives the following output >>
java.lang.NoClassDefFoundError: org/objectweb/asm/Opcodes
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.getConstructor(Class.java:1657)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:43)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.Opcodes
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 30 more
Further investigation >
This link shows jars that contain Opcodes and I've added this dependency I found here
<dependency>
<groupId>asm</groupId>
<artifactId>asm-all</artifactId>
<version>2.2</version>
</dependency>
I've added this as the first dependency in the pom and I still get NoClassDefFound for OpCodes.
Finally found something that seems to work :: have added <classifier>jar-with-dependencies</classifier> to the robolectric dependency and the tests finally run.
I see you have
<dependency>
<groupId>org.robolectric</groupId>
<artifactId>robolectric</artifactId>
<version>2.0-alpha-1</version>
<scope>test</scope>
</dependency>
and then
<dependency>
<groupId>org.robolectric</groupId>
<artifactId>robolectric</artifactId>
<version>2.0-rc2</version>
<scope>test</scope>
</dependency>
I don't believe you can have the same dependency listed twice like that and have the app compile but I may be wrong.
None the less, try updating some of your dependency versions. I'm using junit 4.10 with success, along with robolectric 2.1 (2.0 worked as well when I was using that), then mockito is at 1.9.5 as well.
I recommend checking maven central for latest dependencies. I believe there were issues with jUnit 4.11 and robolectric previously though so I haven't tried to upgrade that to 4.11 yet.

Core libraries with android maven plugin

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.

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