Maven top-level exception in Android project - android

I have an Android project which I want to handle with Maven. I am pretty new to Maven so every step I have another bug to solve. I need to add this is pretty huge project with a lot of libraries.
Here is an error :
[
INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class
[INFO] (org.apache.commons.logging.LogFactory$6) that doesn't come with an
[INFO] associated EnclosingMethod attribute. This class was probably produced by a
[INFO] compiler that did not target the modern .class file format. The recommended
[INFO] solution is to recompile the class from source, using an up-to-date compiler
[INFO] and without specifying any "-target" type options. The consequence of ignoring
[INFO] this warning is that reflective operations on this class will incorrectly
[INFO] indicate that it is *not* an inner class.
[INFO]
[INFO] UNEXPECTED TOP-LEVEL EXCEPTION:
[INFO] java.lang.IllegalArgumentException: already added: Lorg/apache/http/annotation/NotThreadSafe;
[INFO] at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[INFO] at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[INFO] at com.android.dx.command.dexer.Main.processClass(Main.java:490)
[INFO] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
[INFO] at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[INFO] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[INFO] at com.android.dx.command.dexer.Main.processOne(Main.java:422)
[INFO] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
[INFO] at com.android.dx.command.dexer.Main.run(Main.java:209)
[INFO] at com.android.dx.command.dexer.Main.main(Main.java:174)
[INFO] at com.android.dx.command.Main.main(Main.java:91)
[INFO]
[INFO] UNEXPECTED TOP-LEVEL EXCEPTION:
[INFO] java.lang.IllegalArgumentException: already added: Lcom/google/inject/AbstractModule;
[INFO] at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[INFO] at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[INFO] at com.android.dx.command.dexer.Main.processClass(Main.java:490)
[INFO] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
[INFO] at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[INFO] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[INFO] at com.android.dx.command.dexer.Main.processOne(Main.java:422)
[INFO] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
[INFO] at com.android.dx.command.dexer.Main.run(Main.java:209)
[INFO] at com.android.dx.command.dexer.Main.main(Main.java:174)
[INFO] at com.android.dx.command.Main.main(Main.java:91)
and my pom.xml, some of the libraries come from Maven Central and some of them I added localy to my Maven repo.
<dependencies>
<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>support-v4</artifactId>
<version>r7</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>20030203.000550</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>12.0.1</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>2.0-no_aop</version>
</dependency>
<dependency>
<groupId>http-client</groupId>
<artifactId>http-client-android</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.2.5</version>
</dependency>
<dependency>
<groupId>local.admobsdk</groupId>
<artifactId>admobsdk</artifactId>
<version>6.4.1</version>
</dependency>
<dependency>
<groupId>local.kicalls</groupId>
<artifactId>kicalls</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>org.roboguice</groupId>
<artifactId>roboguice</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>oauth.signpost</groupId>
<artifactId>signpost-commonshttp4</artifactId>
<version>1.2.1.1</version>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>2.1.11</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.6.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>
<path>/Users/asd/Desktop/sdk</path>
<platform>14</platform>
</sdk>
<deleteConflictingFiles>true</deleteConflictingFiles>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
<attachSources>false</attachSources>
<proguard>
<skip>true</skip>
</proguard>
</configuration>
<extensions>true</extensions>
</plugin>
They say on the internet, that I should add exclusion to these two classes who produce this top-level exception, but have no clue what exclusion I shoud add.

I guess you have a problem with the following dependencies:
1) roboguice and guice. To resolve, I suggest you to exclude com.google.inject:guice from org.roboguice:roboguice dependencies.
2) httpmime have a dependency to httpcore. And I guess this dependency is conflicting with old httpcomponents library embedded in android os. So you can try to exclude org.apache.httpcomponents:httpcore from dependencies of org.apache.httpcomponents:httpmime
Remark: as an alternative to the first suggested exclusion, you can simply try to remove the com.google.inject:guice dependency from your pom since a newer version (3.0) will be present as a transitive dependency of org.roboguice:roboguice
Tip: you can use the command line mvn dependency:tree to have a good vision of all libraries and transitive dependencies of your project.

ben75 answer is correct. But there is another way to handle it. I've just added by hand all libraries to local repository and no exceptions was needed. Here is how to do this : Installing own jar library for Maven dependency

I struggled with a very similar problem. Other found solutions didn't worked for me so I wanted to share my workaraond. My environment: Android 4.3, api 18, plugin Maven Android 3.1.1, maven 3.0.5. I continued getting:
UNEXPECTED TOP-LEVEL EXCEPTION:
[INFO] java.lang.IllegalArgumentException: already added:
Lorg/apache/commons/collections/FastHashMap;
I built commenting out other dependencies (all but those indicated by Vogel in http://www.vogella.com/articles/AndroidBuildMaven/article.html), getting BUILD SUCCESS. Then I decommented the rest of my pom and it worked.

Maybe it's a bit late for the answer, but I just got into the same problem. I just added this chunk in the pom file:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.3.5</version>
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>
and builds just nice, since the dependency was being included twice :)

Related

unable to compile Maven project after switching to ADT

I've switched from Eclipse Indigo to ADT (version 22.3.0)
I compile a project using Maven through command line:
mvn clean install android:deploy android:run
The project compiled fine on my older system and I haven't changed it at all. Now when I import it to ADT I get the "already added" error during compilation:
...
[INFO] UNEXPECTED TOP-LEVEL EXCEPTION:
[INFO] java.lang.IllegalArgumentException: already added: Lcom/sun/activation/registries/LineTokenizer;
[INFO] at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[INFO] at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[INFO] at com.android.dx.command.dexer.Main.processClass(Main.java:490)
[INFO] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
[INFO] at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[INFO] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[INFO] at com.android.dx.command.dexer.Main.processOne(Main.java:422)
[INFO] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
[INFO] at com.android.dx.command.dexer.Main.run(Main.java:209)
[INFO] at com.android.dx.command.dexer.Main.main(Main.java:174)
[INFO] at com.android.dx.command.Main.main(Main.java:91)
[INFO] 1 error; aborting
...
I don't have X_src files I saw on other replies to this issue. I don't include any library in my lib folder either.
This happens even with basic POM file so I guess that ADT has changed the project somehow so it includes this LineTokenizer twice (I'm not including it anywhere), is this correct?
Does anyone know how to fix this, or to find where the multiple inclusions happen?
Edit:
the POM:
<?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>my.package</groupId>
<artifactId>android-client</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>Name</name>
<dependencies>
<dependency>
<groupId>com.google.android.services</groupId>
<artifactId>google-play-services</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>com.google.android.support</groupId>
<artifactId>android-support-v4</artifactId>
<version>4</version>
</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.analytics</groupId>
<artifactId>analytics</artifactId>
<version>3</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>oauth.signpost</groupId>
<artifactId>signpost-core</artifactId>
<version>1.2.1.1</version>
</dependency>
<dependency>
<groupId>oauth.signpost</groupId>
<artifactId>signpost-commonshttp4</artifactId>
<version>1.2.1.1</version>
</dependency>
<dependency>
<groupId>com.facebook.android</groupId>
<artifactId>facebook-android-sdk</artifactId>
<version>3.5.2</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.flurry</groupId>
<artifactId>FlurryAgent</artifactId>
<version>3.2.2</version>
</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>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<platform>11</platform>
</sdk>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
</plugins>
</build>
</project>
The ADT will throw that error if its finds more than one instance of the same package but with different version number to them. Looking at your pom one of your dependencies is adding the LineTokenizer which is not up-to-date in comparison to the one supplied by the compiler. I would suggest you go to the Dependency Hierarchy using the maven POM Editor. This will allow you to select the extraneous dependency, which you can then exclude by right-clicking and selecting "Exclude Maven Artifact..." which will automatically add an <exclusions> element to your POM. This will remove the duplicate JAR from your Eclipse classpath and allow you to build you project. Do a mvn clean install after you done editing the POM though.

Android Maven Instrumentation Tests with Robotium returns IllegalAccessError

I have have my android application integration tests.
When I try to run them from maven I get error below. I read here that I should use <scope>provieded</scope>, but then I get compilation errors like "package not found"...
Attaching integration test pom.xml.
[INFO] --- android-maven-plugin:3.5.3:internal-integration-test (default-internal-integration-test) # md-lt-tests ---
[INFO] Found 1 devices connected with the Android Debug Bridge
[INFO] android.device parameter not set, using all attached devices
[INFO] Emulator emulator-5554_Test_unknown_sdk found.
[INFO] emulator-5554_Test_unknown_sdk : Running instrumentation tests in lt.ito.md.tests
[INFO] emulator-5554_Test_unknown_sdk : Run started: lt.md.md.tests, 0 tests:
[INFO] emulator-5554_Test_unknown_sdk : Run failed: Instrumentation run failed due to 'java.lang.IllegalAccessError'
[INFO] emulator-5554_Test_unknown_sdk : Run ended: 0 ms
[INFO] Tests run: 0, Failures: 0, Errors: 0
[INFO] emulator-5554_Test_unknown_sdk : Report file written to /home/martynas/work/md-android/md/lt/lt-tests/target/surefire-reports/TEST-emulator-5554_Test_unknown_sdk.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:20.297s
[INFO] Finished at: Sun Apr 21 18:31:30 EEST 2013
[INFO] Final Memory: 22M/307M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.5.3:internal-integration-test (default-internal-integration-test) on project md-lt-tests: emulator-5554_Test_unknown_sdk : Test run failed to complete: Instrumentation run failed due to 'java.lang.IllegalAccessError'
Integration tests 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>company</groupId>
<artifactId>md-lt</artifactId>
<version>1.5.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>md-lt-tests</artifactId>
<packaging>apk</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>md-lt-app</artifactId>
<version>${project.version}</version>
<type>apk</type>
</dependency>
<dependency>
<groupId>com.jayway.android.robotium</groupId>
<artifactId>robotium-solo</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<finalName>${project.artifactId}</finalName>
<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.5.3</version>
<extensions>true</extensions>
<configuration>
<sdk>
<platform>${android.platform.version}</platform>
</sdk>
</configuration>
</plugin>
</plugins>
</build>
</project>
Found solution here
Test project should have both apk and jar dependencies and both should have <scope>provided</scope>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>md-lt-app</artifactId>
<version>${project.version}</version>
<scope>provied</scope>
<type>apk</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>md-lt-app</artifactId>
<version>${project.version}</version>
<scope>provied</scope>
<type>jar</type>
</dependency>

Maven cannot find external jar's annotations

I'm converting a simple android app to Maven, and I've hit a snag with a 3rd party jar (ActiveAndroid) that contains an annotation class that I'm using within my code. I've confirmed that the jar does contain the annotations class files, and the jar works fine when I include it in the libs directory, and compile with Eclipse.
Here's my POM.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>
<groupId>com.danh32</groupId>
<artifactId>testapp</artifactId>
<version>1.0</version>
<packaging>apk</packaging>
<name>testapp</name>
<properties>
<platform.version> 4.1.1.4</platform.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>actionbarsherlock</artifactId>
<version>4.2.0</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.activeandroid</groupId>
<artifactId>activeandroid</artifactId>
<version>LATEST</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.5.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>16</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
And here's my compilation error:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.339s
[INFO] Finished at: Wed Apr 10 14:18:51 CDT 2013
[INFO] Final Memory: 17M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project testapp: Compilation failure: Compilation failure:
[ERROR] /Users/danh32/code/android/workspace-android/TestApp/src/com/danh32/testapp/db/DSLocation.java:[9,43] cannot find symbol
[ERROR] symbol : class ConflictAction
[ERROR] location: #interface com.activeandroid.annotation.Column
[ERROR] /Users/danh32/code/android/workspace-android/TestApp/src/com/danh32/testapp/db/DSLocation.java:[15,32] cannot find symbol
[ERROR] symbol : method unique()
[ERROR] location: #interface com.activeandroid.annotation.Column
[ERROR] /Users/danh32/code/android/workspace-android/TestApp/src/com/danh32/testapp/db/DSLocation.java:[15,47] cannot find symbol
[ERROR] symbol : method onUniqueConflict()
[ERROR] location: #interface com.activeandroid.annotation.Column
[ERROR] /Users/danh32/code/android/workspace-android/TestApp/src/com/danh32/testapp/db/DSLocation.java:[15,66] cannot find symbol
[ERROR] symbol : variable ConflictAction
[ERROR] location: class com.danh32.testapp.db.DSLocation
[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.
I'm just starting out with Maven and compiling Android apps outside of Eclipse, so I'm sure I'm missing something simple. Any nudge in the right direction is highly appreciated!
Thanks!
You're using LATEST. Is it possible you have more than one version of that artifact, and Maven is picking up a different one from Eclipse?
it doesn't look like the active android artifact is available in the Maven Central Repo (see this search). You can install that jar in your own local repository (using mvn install-file but that will only work on your local machine. Alternatively you can deploy that artifact to a repository that you control and reference that in your POM.
Have you considered class version problem? Just speculating, but it could be that the jar was built using 1.6 JDK (target 1.6) Your POM has specified the source and target as 1.5, considering you are also using 1.5 JDK, it is possible that the compiler is simply not able to read the classes in your jar file compiled with 1.6

android maven mojoexception

I'm new to Android maven integration in to sonar dashboard. My aim is thru Android JUnit to get the code coverage using Emma and integrate that into sonar dashboard.
I'm facing difficulties in doing that and i'm getting the following exception. When run the development project with the below command
mvn clean install -Pemma
Please find the maven details below,
Apache Maven 3.0.4 (r1232337; 2012-01-17 14:14:56+0530)
Maven home: G:\Projects\apache-maven-3.0.4-bin\apache-maven-3.0.4\bin\..
Java version: 1.6.0, vendor: Sun Microsystems Inc.
Java home: C:\Program Files\Java\jdk1.6.0\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows vista", version: "6.1", arch: "x86", family: "windows"
http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
<parent>
<groupId>andersen.project</groupId>
<artifactId>Hello-parent</artifactId>
<version>1.0</version>
</parent>
<groupId>andersen.project</groupId>
<artifactId>MyProject</artifactId>
<packaging>apk</packaging>
<version>1.0</version>
<name>MyProject- Application</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.0</version>
<scope>system</scope>
<systemPath>E:\android_sdk\add-ons\addon-google_apis-google_inc_-14\libs\maps.jar</systemPath>
</dependency>
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<systemPath>E:\android_sdk\platforms\android-14\android.jar</systemPath>
<version>4.0</version>
<scope>system</scope>
</dependency>
<dependency>
<groupId>deps</groupId>
<artifactId>dep1</artifactId>
<version>0.1</version>
<scope>system</scope>
<systemPath>${basedir}/libs/acra-4.2.3.jar</systemPath>
</dependency>
<dependency>
<groupId>deps</groupId>
<artifactId>dep2</artifactId>
<version>0.1</version>
<scope>system</scope>
<systemPath>${basedir}/libs/GoogleAdMobAdsSdk-6.1.0.jar</systemPath>
</dependency>
<dependency>
<groupId>deps</groupId>
<artifactId>dep3</artifactId>
<version>0.1</version>
<scope>system</scope>
<systemPath>${basedir}/libs/GSAndroidSDK.jar</systemPath>
</dependency>
<dependency>
<groupId>deps</groupId>
<artifactId>dep4</artifactId>
<version>0.1</version>
<scope>system</scope>
<systemPath>${basedir}/libs/GSAndroidSDK_src.jar</systemPath>
</dependency>
<dependency>
<groupId>deps</groupId>
<artifactId>dep5</artifactId>
<version>0.1</version>
<scope>system</scope>
<systemPath>${basedir}/libs/MMBrandedSDK.jar</systemPath>
</dependency>
<dependency>
<groupId>deps</groupId>
<artifactId>dep6</artifactId>
<version>0.1</version>
<scope>system</scope>
<systemPath>${basedir}/bin/classes.dex</systemPath>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<profiles>
<profile>
<id>emma</id>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.4.1</version>
<configuration> <!-- emma start -->
<emma>
<enable>true</enable>
<classFolders>${project.basedir}/target/classes/</classFolders>
<outputMetaFile>${project.basedir}/target/emma/coverage.em</outputMetaFile>
</emma> <!-- emma stop -->
<dex>
<noLocals>true</noLocals> <!-- must be set for emma -->
</dex>
</configuration>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<properties>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.emma.reportPath>target/emma/</sonar.emma.reportPath>
<sonar.surefire.reportsPath>../regalandroid-test/target/surefire-reports</sonar.surefire.reportsPath>
<sonar.core.codeCoveragePlugin>emma</sonar.core.codeCoveragePlugin>
</properties>
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Hello - Parent
[INFO] sourcecode - Application
[INFO] SourceCode - Integration tests
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Hello - Parent 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # Hello-parent ---
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) # Hello-parent ---
[INFO] Installing G:\Projects\pom.xml to C:\Users\myuser\.m2\repository\andersen\project\Hello-parent\1.0\Hello-parent-1.0.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SourceCode - Application 1.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.google.android:android:jar:4.0 is missing, no dependency information available
[WARNING] The POM for android:android:jar:4.0 is missing, no dependency information available
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Skipping Hello - Parent
[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Hello - Parent .................................... SUCCESS [1.157s]
[INFO] SourceCode - Application ....................... FAILURE [0.348s]
[INFO] SourceCode - Integration tests ................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.703s
[INFO] Finished at: Thu Dec 06 13:32:20 IST 2012
[INFO] Final Memory: 4M/8M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project SourceCode: Could not resolve dependencies for project andersen.project:SourceCode:jar:1.0: The following artifacts could not be resolved: com.google.android:android:jar:4.0, android:android:jar:4.0: Failure to find com.google.android:android:jar:4.0 in http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [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/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :SourceCode
It would be great, if anyone give me step by step how to use.
Thanks in Advance

android-maven-plugin causes java.lang.OutOfMemoryError when trying to create dex

I need a hand. I'm using android-maven-plugin 3.0.0 and maven-external-dependency-plugin 0.4 in an android project. I'm using these libraries from different repositories as dependencies:
<dependencies>
<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>
<dependency>
<groupId>com.admob.android.ads</groupId>
<artifactId>admob-android</artifactId>
<version>4.0.4</version>
</dependency>
<dependency>
<groupId>com.google.code</groupId>
<artifactId>google-api-translate-java</artifactId>
<version>0.97</version>
</dependency>
<dependency>
<groupId>com.db4o</groupId>
<artifactId>db4o-core-java5</artifactId>
<version>${com.db4o.version}</version>
</dependency>
<dependency>
<groupId>com.db4o</groupId>
<artifactId>db4o-cs-java5</artifactId>
<version>${com.db4o.version}</version>
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-mime4j</artifactId>
<version>0.6</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency>
<groupId>org.restlet.jee</groupId>
<artifactId>org.restlet</artifactId>
<version>${restlet.version}</version>
</dependency>
</dependencies>
Dependencies are all satisfied but when it's time to ingrate all jars into Android dex I get an out of memory error:
[INFO] UNEXPECTED TOP-LEVEL ERROR:
[INFO] java.lang.OutOfMemoryError: Java heap space
[INFO] at com.android.dx.cf.code.OneLocalsArray.<init>(OneLocalsArray.java:46)
[INFO] at com.android.dx.cf.code.OneLocalsArray.copy(OneLocalsArray.java:51)
[INFO] at com.android.dx.cf.code.OneLocalsArray.copy(OneLocalsArray.java:33)
[INFO] at com.android.dx.cf.code.Frame.copy(Frame.java:98)
[INFO] at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:683)
[INFO] at com.android.dx.cf.code.Ropper.doit(Ropper.java:639)
[INFO] at com.android.dx.cf.code.Ropper.convert(Ropper.java:252)
[INFO] at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:256)
[INFO] at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:134)
[INFO] at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:87)
[INFO] at com.android.dx.command.dexer.Main.processClass(Main.java:483)
[INFO] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
[INFO] at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[INFO] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[INFO] at com.android.dx.command.dexer.Main.processOne(Main.java:418)
[INFO] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
[INFO] at com.android.dx.command.dexer.Main.run(Main.java:206)
[INFO] at com.android.dx.command.dexer.Main.main(Main.java:174)
[INFO] at com.android.dx.command.Main.main(Main.java:95)
Trying to increase memory adding this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>pertest</forkMode>
<argLine>-Xms1024m -Xmx2048m</argLine>
<testFailureIgnore>false</testFailureIgnore>
<skip>false</skip>
</configuration>
</plugin>
or this:
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<argLine>-Xmx1024m</argLine>
...
or exporting maven_opts like this:
export MAVEN_OPTS=-Xmx1024m
do not solve the problem
I get several warnings about classes in dependent files being compiled with an old class format but I'm not sure that is the source of the problem:
[INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class
[INFO] (org.osgi.framework.AdminPermission$1) that doesn't come with an
[INFO] associated EnclosingMethod attribute. This class was probably produced by a
[INFO] compiler that did not target the modern .class file format. The recommended
[INFO] solution is to recompile the class from source, using an up-to-date compiler
[INFO] and without specifying any "-target" type options. The consequence of ignoring
[INFO] this warning is that reflective operations on this class will incorrectly
[INFO] indicate that it is *not* an inner class.
I would appreciate any help. Here's a full output with debugging turned on from the console so you can take a closer look at the error:
http://pastebin.com/5DPBihH0
Best.
Dama
This was a known issue, but I believe it was fixed in the android-maven-plugin version 3.1.0. The latest is 3.1.1. You didn't post your pom.xml so I can't tell if that's the issue, but it sounds like it is.
If you can't upgrade for some reason, this is the configuration that applies:
<dex>
<jvmArguments>
<jvmArgument>-Xms256m</jvmArgument>
<jvmArgument>-Xmx512m</jvmArgument>
</jvmArguments>
</dex>
Here's the issue reported on their site: http://code.google.com/p/maven-android-plugin/issues/detail?id=146
And also in the Springsource blog: http://blog.springsource.org/2011/11/07/updated-maven-support-for-android-projects/
I think it's connected with those warnings:
[INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class
[INFO] (org.osgi.framework.AdminPermission$1) that doesn't come with an
[INFO] associated EnclosingMethod attribute. This class was probably produced by a
[INFO] compiler that did not target the modern .class file format. The recommended
[INFO] solution is to recompile the class from source, using an up-to-date compiler
[INFO] and without specifying any "-target" type options. The consequence of ignoring
[INFO] this warning is that reflective operations on this class will incorrectly
[INFO] indicate that it is *not* an inner class.
Answers that should help you:
"Ignoring InnerClasses attribute" warning is killing Eclipse
What is the "Ignoring InnerClasses attribute" warning output during compilation?
http://code.google.com/p/maven-android-plugin/issues/detail?id=26

Categories

Resources