IllegalArgumentException on Android Maven Install - android

I am getting the following exception when attempting a "mvn install" on an Android project.
[INFO] UNEXPECTED TOP-LEVEL EXCEPTION:
[INFO] java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl;
[INFO] at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
[INFO] at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
[INFO] at com.android.dx.command.dexer.Main.processClass(Main.java:685)
[INFO] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
[INFO] at com.android.dx.command.dexer.Main.access$600(Main.java:78)
[INFO] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
[INFO] at com.android.dx.command.dexer.Main.processOne(Main.java:596)
[INFO] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
[INFO] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
[INFO] at com.android.dx.command.dexer.Main.run(Main.java:230)
[INFO] at com.android.dx.command.dexer.Main.main(Main.java:199)
[INFO] at com.android.dx.command.Main.main(Main.java:103)
It looks as though there is some kind of dependency conflict. My pom is as follows
<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">
<parent>
<groupId>com.x.y.z</groupId>
<artifactId>parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>android-project</artifactId>
<packaging>apk</packaging>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<platform>19</platform>
<path>${env.ANDROID_HOME}/</path>
</sdk>
<undeployBeforeDeploy>false</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.2</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<version>4.4.2_r3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v4</artifactId>
<version>20.0.0</version>
</dependency>
<dependency>
<groupId>org.androidannotations</groupId>
<artifactId>androidannotations</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>com.mcxiaoke.volley</groupId>
<artifactId>library</artifactId>
<version>1.0.6</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>fr.avianey</groupId>
<artifactId>facebook-android-api</artifactId>
<version>3.17.1</version>
<type>aar</type>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>4.0.2</version>
</dependency>
</dependencies>
</project>
if I make the android support compatibility-v4 dependency provided scope the install runs successfully, but the app crashes at runtime when I run it from IntelliJ as it is unable to inflate the DrawerLayout view.
Any ideas?

For anyone interested, the Facebook api was causing a conflict as it contains the android support v4. I added an exclusion and it works now.

Related

NullPointerException when trying build a android application with maven and plugin com.jayway.maven.plugins.android.generation2

I am trying building a android application with maven and this 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>org.kleber</groupId>
<artifactId>app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>app</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<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>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.2</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>
<emulator>
<avd>avd</avd>
</emulator>
</configuration>
</plugin>
</plugins>
</build>
</project>
and keeping getting this error:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.213 s
[INFO] Finished at: 2019-09-25T22:03:34-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.9.0-rc.2:generate-sources (default-generate-sources) on project app: Execution default-generate-sources of goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.9.0-rc.2:generate-sources failed.: NullPointerException -> [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/PluginExecutionException
Anyone can tell what's the problem here?

how use android:apk of simpligility android-maven-plugin

i know that the com.jayway.maven.plugins.android.generation2 groupId is now also out of date. The groupId of the plugin is now com.simpligility.maven
.plugins.i already try jayway'plugin,it's just ok,when i try simpligility
plugin i have a little trouble.when i use the goal of android:apk,it occur this error:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenTest 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- android-maven-plugin:4.4.1:apk (default-cli) # MavenTest ---
[INFO] Generating debug apk.
[INFO] D:\Tools\EJuno\MavenTest2\target\AndroidManifest.xml: error: Unable to open file for read: No such file or directory
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.887 s
[INFO] Finished at: 2016-05-29T14:23:28+08:00
[INFO] Final Memory: 22M/362M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.simpligility.maven.plugins:android-maven-plugin:4.4.1:apk (default-cli) on project MavenTest: MojoExecutionException: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C "E:\JavaEnvironment\Android-SDK\build-tools\23.0.3\aapt.exe package -f -M D:\Tools\EJuno\MavenTest2\target\AndroidManifest.xml --auto-add-overlay -I E:\JavaEnvironment\Android-SDK\platforms\android-22\android.jar -F D:\Tools\EJuno\MavenTest2\target\MavenTest-0.0.1-SNAPSHOT.ap_ --debug-mode", Result = 1 -> [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/MojoExecutionException
POM.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MavenTest</groupId>
<artifactId>MavenTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.simpligility.maven.plugins</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>4.4.1</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
and i copy AndroidManifest.xml to target folder to have a try,but problem exsit.more and more people use android studio,maybe less use these way.i just want to package a apk with maven.
Here you have my working pom.xml It works for continuously deployment, release, proguarding. Adapt user, password and svn settings and proguard settings (switch to true or false):
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.mydomain</groupId>
<artifactId>myapp</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>MyApp</name>
<scm>
<connection>scm:svn:https://localhost/svn/myproject</connection>
<developerConnection>scm:svn:https://localhost/svn/myproject/myapp</developerConnection>
<url>scm:svn:https://localhost/svn/myrepo</url>
</scm>
<distributionManagement>
<repository>
<id>svnrepo</id>
<url>svn:https://localhost/svn/myproject/myapp/releases</url>
</repository>
<snapshotRepository>
<id>svnrepo</id>
<url>svn:https://localhost/svn/myproject/myapp/snapshots</url>
</snapshotRepository>
</distributionManagement>
<!-- see also properties in settings.xml! -->
<properties>
<android.sdk.path>/opt/android-sdk-linux</android.sdk.path>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.javadoc.skip>true</maven.javadoc.skip>
</properties>
<dependencies>
<!-- android 6 -->
<!-- The dependency was installed by mvn install:install-file -->
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<!-- Dependencies for AdMob -->
<dependency>
<groupId>com.google.android.gms</groupId>
<artifactId>google-play-services</artifactId>
<version>26.0.0</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.google.android.gms</groupId>
<artifactId>google-play-services</artifactId>
<version>26.0.0</version>
<type>jar</type>
</dependency>
<!-- Compatibilty packages: FragmentActivity, NavigationDrawer,... -->
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v4</artifactId>
<version>23.0.0</version>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7-appcompat</artifactId>
<version>23.0.0</version>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7-appcompat</artifactId>
<version>23.0.0</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>design</artifactId>
<version>23.0.0</version>
<type>aar</type>
<exclusions>
<exclusion>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
</exclusion>
<exclusion>
<groupId>com.android.support</groupId>
<artifactId>support-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>com.android.support</groupId>
<artifactId>support-v4</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<outputDirectory>target/classes</outputDirectory>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.9.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
</plugin>
<plugin>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.2</version>
<configuration>
<finalName>${project.artifactId}-${project.version}</finalName>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>4.0.0-rc.1</version>
<extensions>true</extensions>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
<genDirectory>${project.basedir}/gen</genDirectory>
<sdk>
<platform>23</platform>
<path>${android.sdk.path}</path>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
<proguard>
<skip>true</skip>
<config>proguard.cfg</config>
</proguard>
<sign>
<debug>${debug}</debug>
</sign>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<versionRange>4.0.0-rc.1</versionRange>
<goals>
<goal>generate-sources</goal>
<goal>proguard</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>devel</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<debug>true</debug>
</properties>
</profile>
<profile>
<id>release</id>
<properties>
<debug>false</debug>
</properties>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<dependencies>
<dependency>
<groupId>org.jvnet.wagon-svn</groupId>
<artifactId>wagon-svn</artifactId>
<version>1.12</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<id>signing</id>
<goals>
<goal>sign</goal>
</goals>
<phase>package</phase>
<inherited>true</inherited>
<configuration>
<archiveDirectory />
<includes>
<include>target/${project.artifactId}-${project.version}.apk</include>
</includes>
<keystore>${android.keystore}</keystore>
<storepass>${key.password}</storepass>
<keypass>${key.password}</keypass>
<alias>${key.alias}</alias>
<arguments>
<argument>-verbose</argument>
<argument>-sigalg</argument>
<argument>MD5withRSA</argument>
<argument>-digestalg</argument>
<argument>SHA1</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<!-- Since non-release builds are now debuggable by default you NEED TO ensure that the release parameter is set to true in your release build. -->
<release>true</release>
<zipalign>
<verbose>true</verbose>
<skip>false</skip>
<inputApk>${project.build.directory}/${project.artifactId}-${project.version}.apk</inputApk>
<outputApk>${project.build.directory}/${project.artifactId}-${project.version}-RELEASE.apk</outputApk>
</zipalign>
</configuration>
<executions>
<execution>
<id>zipalign</id>
<phase>install</phase>
<goals>
<goal>zipalign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>svnrepo</id>
<username>myuser</username>
<password>mypassword</password>
</server>
</servers>
<mirrors>
</mirrors>
<profiles>
<profile>
<id>outsorced-project-properties</id>
<properties>
<android.keystore>/home/myuser/.android/release.keystore</android.keystore>
<key.password>mykeystorepassword</key.password>
<key.alias>androidreleasekey</key.alias>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>outsorced-project-properties</activeProfile>
</activeProfiles>
</settings>
Continuously builds and deployments on the device are executed by:
clean install android:deploy android:run
Release management works with:
mvn -X release:prepare -Darguments=-Dusername=youruser -Dpassword=yourpassword
mvn -X release:perform -Darguments=-Dusername=youruser -Dpassword=yourpassword
For the Google support libraries you also have to install https://github.com/simpligility/maven-android-sdk-deployer

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.

How to import both ViewPagerIndicator and ActionBarSherlock?

If i only using ViewPagerIndicator as dependency project, then everything goes fine. But after i import ActionBarSherlock, something wrong happens.
Here is the output log:
125 || [INFO] ------------------------------------------------------------------------
126 || [INFO] BUILD FAILURE
127 || [INFO] ------------------------------------------------------------------------
128 || [INFO] Total time: 33.129s
129 || [INFO] Finished at: Thu Sep 19 14:33:23 CST 2013
130 || [INFO] Final Memory: 19M/102M
131 || [INFO] ------------------------------------------------------------------------
132 || [ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.2-SNAPSHOT:dex (default-dex) on project rms: MojoExecutionException: ANDROID-040-001: Could not execute: Command = /bin/sh -c cd /Users/ccheng/workspace/rms && /System/Library/Java/JavaVirtualMachines/1.6.0. jdk/Contents/Home/bin/java -Xmx1024M -jar /Users/ccheng/program/adt-bundle-mac-x86_64-20130219/sdk/build-tools/18.0.1/lib/dx.jar --dex --output=/Users/ccheng/ workspace/rms/target/classes.dex /Users/ccheng/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar /Users/ccheng/.m2/repository/com/google/ code/gson/gson/2.2.4/gson-2.2.4.jar /Users/ccheng/.m2/repository/com/biubiubiu/indexablelistview-lib2/1.0.0-SNAPSHOT/indexablelistview-lib2-1.0.0-SNAPSHOT.apklib / Users/ccheng/.m2/repository/com/biubiubiu/indexablelistview-lib1/1.0.0-SNAPSHOT/indexablelistview-lib1-1.0.0-SNAPSHOT.apklib /Users/ccheng/.m2/repository/com/novoda/ imageloader/imageloader-core/1.5.8/imageloader-core-1.5.8.jar /Use
133 || rs/ccheng/.m2/repository/com/github/chrisbanes/pulltorefresh/library/2.1.1/library-2.1.1.apklib /Users/ccheng/workspace/rms/target/classes /Users/ccheng/.m2/ repository/com/tjerkw/slideexpandablelistview-library/1.1.0-SNAPSHOT/slideexpandablelistview-library-1.1.0-SNAPSHOT.apklib /Users/ccheng/.m2/repository/com/google/ android/support-v4/r7/support-v4-r7.jar /Users/ccheng/.m2/repository/msx/android/preferences/libraryprojects-lib1/1.0.0-SNAPSHOT/libraryprojects-lib1-1.0.0-SNAPSHOT. apklib /Users/ccheng/.m2/repository/com/actionbarsherlock/actionbarsherlock/4.3.1/actionbarsherlock-4.3.1.apklib /Users/ccheng/.m2/repository/com/meishixing/android- async-http/1.4.2/android-async-http-1.4.2.jar /Users/ccheng/.m2/repository/com/viewpagerindicator/library/2.4.1/library-2.4.1.apklib /Users/ccheng/.m2/repository/ android/support/compatibility-v4/18/compatibility-v4-18.jar, Result = 1 -> [Help 1]
134 || [ERROR]
135 || [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
136 || [ERROR] Re-run Maven using the -X switch to enable full debug logging.
137 || [ERROR]
138 || [ERROR] For more information about the errors and possible solutions, please read the following articles:
139 || [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
140 || make: *** [main] Error 1
➜ /tmp /bin/sh -c cd /Users/ccheng/workspace/rms && /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -Xmx1024M -jar /Users/ccheng/program/adt-bundle-mac-x86_64-20130219/sdk/build-tools/18.0.1/lib/dx.jar --dex --output=/Users/ccheng/workspace/rms/target/classes.dex /Users/ccheng/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar /Users/ccheng/.m2/repository/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar /Users/ccheng/.m2/repository/com/biubiubiu/indexablelistview-lib2/1.0.0-SNAPSHOT/indexablelistview-lib2-1.0.0-SNAPSHOT.apklib /Users/ccheng/.m2/repository/com/biubiubiu/indexablelistview-lib1/1.0.0-SNAPSHOT/indexablelistview-lib1-1.0.0-SNAPSHOT.apklib /Users/ccheng/.m2/repository/com/novoda/imageloader/imageloader-core/1.5.8/imageloader-core-1.5.8.jar /Users/ccheng/.m2/repository/com/github/chrisbanes/pulltorefresh/library/2.1.1/library-2.1.1.apklib /Users/ccheng/workspace/rms/target/classes /Users/ccheng/.m2/repository/com/tjerkw/slideexpandablelistview-library/1.1.0-SNAPSHOT/slideexpandablelistview-library-1.1.0-SNAPSHOT.apklib /Users/ccheng/.m2/repository/com/google/android/support-v4/r7/support-v4-r7.jar /Users/ccheng/.m2/repository/msx/android/preferences/libraryprojects-lib1/1.0.0-SNAPSHOT/libraryprojects-lib1-1.0.0-SNAPSHOT.apklib /Users/ccheng/.m2/repository/com/actionbarsherlock/actionbarsherlock/4.3.1/actionbarsherlock-4.3.1.apklib /Users/ccheng/.m2/repository/com/meishixing/android-async-http/1.4.2/android-async-http-1.4.2.jar /Users/ccheng/.m2/repository/com/viewpagerindicator/biubiubiu-library/2.4.1/biubiubiu-library-2.4.1.apklib /Users/ccheng/.m2/repository/android/support/compatibility-v4/18/compatibility-v4-18.jar
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/FragmentManagerState;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
at com.android.dx.command.dexer.Main.processClass(Main.java:490)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
at com.android.dx.command.dexer.Main.access$400(Main.java:67)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
at com.android.dx.command.dexer.Main.processOne(Main.java:422)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
at com.android.dx.command.dexer.Main.run(Main.java:209)
at com.android.dx.command.dexer.Main.main(Main.java:174)
at com.android.dx.command.Main.main(Main.java:91)
This is 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>me.biubiubiu.rms</groupId>
<artifactId>rms</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>rms</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<fest-assert.version>1.0.4</fest-assert.version>
<junit.version>4.10</junit.version>
<robolectric.version>2.0</robolectric.version>
<android.version>4.1.1.4</android.version>
<android-support.version>r13</android-support.version>
</properties>
<dependencies>
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<version>4.2.2_r2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v4</artifactId>
<version>18</version>
</dependency>
<dependency>
<groupId>com.tjerkw</groupId>
<artifactId>slideexpandablelistview-library</artifactId>
<version>1.1.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.meishixing</groupId>
<artifactId>android-async-http</artifactId>
<version>1.4.2</version>
<type>jar</type>
</dependency>
<!--<dependency>-->
<!--<groupId>com.</groupId>-->
<!--<artifactId>biubiubiu-library</artifactId>-->
<!--<version>2.4.1</version>-->
<!--<type>apklib</type>-->
<!--</dependency>-->
<dependency>
<groupId>com.viewpagerindicator</groupId>
<artifactId>library</artifactId>
<version>2.4.1</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.github.chrisbanes.pulltorefresh</groupId>
<artifactId>library</artifactId>
<version>2.1.1</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.novoda.imageloader</groupId>
<artifactId>imageloader-core</artifactId>
<version>1.5.8</version>
</dependency>
<dependency>
<groupId>com.biubiubiu</groupId>
<artifactId>indexablelistview-lib2</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup</groupId>
<artifactId>fest-android</artifactId>
<version>${fest-assert.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.robolectric</groupId>
<artifactId>robolectric</artifactId>
<version>${robolectric.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>msx.android.preferences</groupId>
<artifactId>libraryprojects-lib1</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>actionbarsherlock</artifactId>
<version>4.3.1</version>
<type>apklib</type>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.6.2-SNAPSHOT</version>
<configuration>
<sdk>
<platform>17</platform>
</sdk>
<manifest>
<debuggable>true</debuggable>
</manifest>
</configuration>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
<!--jarsign-->
<profiles>
<profile>
<id>sign</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>signing</id>
<goals>
<goal>sign</goal>
</goals>
<phase>package</phase>
<inherited>true</inherited>
<configuration>
<archiveDirectory></archiveDirectory>
<includes>
<include>target/*.apk</include>
</includes>
<keystore>/Users/ccheng/workspace/msx-crazysight/meishixing.keystore</keystore>
<storepass>meishigo</storepass>
<keypass>meishigo</keypass>
<alias>meishixing</alias>
<arguments>
<argument>-sigalg</argument><argument>MD5withRSA</argument>
<argument>-digestalg</argument><argument>SHA1</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<sign>
<debug>false</debug>
</sign>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
if the problem is with ActionBarSherlock, try using ActionBarActivity which is available in v7 support library
I found this problem is caused by the v4 library i import is different from ActionBarSherlock.
After i change all the dependency project to
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v4</artifactId>
<version>18</version>
</dependency>
it works find again.

Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.5.0:deploy ... InstallException: TimeoutException

I have been trying to convert my Android project to maven and after some issues I am struggling to deploy. I can clean and install but when it comes to the deploy I get the error:
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.5.0:deploy (default-cli) on project mega: Uninstall of org.jointsecurityarea.android.mega failed. InstallException: TimeoutException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.5.0:deploy (default-cli) on project mega: Uninstall of org.jointsecurityarea.android.mega failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Uninstall of org.jointsecurityarea.android.mega failed.
at com.jayway.maven.plugins.android.AbstractAndroidMojo$2.doWithDevice(AbstractAndroidMojo.java:806)
at com.jayway.maven.plugins.android.AbstractAndroidMojo.doWithDevices(AbstractAndroidMojo.java:715)
at com.jayway.maven.plugins.android.AbstractAndroidMojo.undeployApk(AbstractAndroidMojo.java:792)
at com.jayway.maven.plugins.android.AbstractAndroidMojo.undeployApk(AbstractAndroidMojo.java:776)
at com.jayway.maven.plugins.android.AbstractAndroidMojo.deployApk(AbstractAndroidMojo.java:600)
at com.jayway.maven.plugins.android.AbstractAndroidMojo.deployBuiltApk(AbstractAndroidMojo.java:670)
at com.jayway.maven.plugins.android.standalonemojos.DeployMojo.execute(DeployMojo.java:57)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: com.android.ddmlib.InstallException
at com.android.ddmlib.Device.uninstallPackage(Device.java:687)
at com.jayway.maven.plugins.android.AbstractAndroidMojo$2.doWithDevice(AbstractAndroidMojo.java:798)
... 27 more
Caused by: com.android.ddmlib.TimeoutException
at com.android.ddmlib.AdbHelper.read(AdbHelper.java:648)
at com.android.ddmlib.AdbHelper.read(AdbHelper.java:616)
at com.android.ddmlib.AdbHelper.readAdbResponse(AdbHelper.java:216)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:378)
at com.android.ddmlib.Device.executeShellCommand(Device.java:372)
at com.android.ddmlib.Device.uninstallPackage(Device.java:684)
... 28 more
I am attempting to run this from the command line, not using the m2e plugin. Also, here is my 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>org.jointsecurityarea</groupId>
<artifactId>mega</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>apk</packaging>
<name>Mega</name>
<properties>
<platform.version>4.0.1.2</platform.version>
</properties>
<build>
<directory>target</directory>
<outputDirectory>target/classes</outputDirectory>
<finalName>${project.artifactId}-${project.version}</finalName>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<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.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>17</platform>
<path>C:\Android\adt-bundle-windows-x86_64\sdk</path>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
<device>usb</device>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<versionRange>[3.2.0,)</versionRange>
<goals>
<goal>manifest-update</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>fluent-hc</artifactId>
<version>4.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient-cache</artifactId>
<version>4.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.2.3</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
</dependencies>
I am brand new to Maven. Thanks for your help in advance.

Categories

Resources