title: Android and maven: problem with maven dependencies in apk
body: <p>I'm currently working on an Android project using Maven as the build tool. However I'm having a problem with including dependencies, to be more specific: none of the dependencies listed in my pom file are packed in the apk. This results in <code>ClassDefNotFound</code> errors when I'm trying to run the app on my emulator (the underlying <code>ClassNotFound</code> exception is thrown in the Dalvik loader).</p>
  
  <p>I'm using Springsource Tool Suite ( 2.5.2.SR1), with the following plugin configuration:</p>
  
  <ul>
  <li>Android Development Tools (10.0.1.v201103111512-110841)</li>
  <li>Maven integration for Android Development Tools (0.2.5)</li>
  <li>Maven integration for Eclipse (0.12.1.20110112-1712) </li>
  <li>Maven (2.2.1)</li>
  </ul>
  
  <p>This is my pom file</p>
  
  <pre><code>&lt;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"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;android-test&lt;/groupId&gt;
    &lt;artifactId&gt;android-test&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;apk&lt;/packaging&gt;
    &lt;name&gt;android-test&lt;/name&gt;
  
      &lt;properties&gt; 
          &lt;android-platform&gt;10&lt;/android-platform&gt;
          &lt;android-emulator&gt;Android-2.3.3&lt;/android-emulator&gt;
          &lt;android-sdk-path&gt;C:\Program Files\Android\android-sdk&lt;/android-sdk-path&gt;
          &lt;maven-android-plugin-version&gt;2.8.4&lt;/maven-android-plugin-version&gt;
          &lt;maven-compiler-plugin-version&gt;2.3.2&lt;/maven-compiler-plugin-version&gt;
          &lt;android-version&gt;2.3.1&lt;/android-version&gt;
          &lt;spring-android-version&gt;1.0.0.M2&lt;/spring-android-version&gt;
          &lt;jackson-version&gt;1.7.2&lt;/jackson-version&gt;
      &lt;/properties&gt;
  
      &lt;build&gt;
          &lt;sourceDirectory&gt;src&lt;/sourceDirectory&gt;
          &lt;finalName&gt;${project.artifactId}&lt;/finalName&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;com.jayway.maven.plugins.android.generation2&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-android-plugin&lt;/artifactId&gt;
                  &lt;version&gt;${maven-android-plugin-version}&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;sdk&gt;
                          &lt;platform&gt;${android-platform}&lt;/platform&gt;
                          &lt;path&gt;${android-sdk-path}&lt;/path&gt;
                      &lt;/sdk&gt;
                      &lt;emulator&gt;
                          &lt;avd&gt;${android-emulator}&lt;/avd&gt;
                      &lt;/emulator&gt;
                      &lt;deleteConflictingFiles&gt;false&lt;/deleteConflictingFiles&gt;
                      &lt;undeployBeforeDeploy&gt;true&lt;/undeployBeforeDeploy&gt;
                  &lt;/configuration&gt;
                  &lt;extensions&gt;true&lt;/extensions&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;${maven-compiler-plugin-version}&lt;/version&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.google.android&lt;/groupId&gt;
              &lt;artifactId&gt;android&lt;/artifactId&gt;
              &lt;version&gt;${android-version}&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.android&lt;/groupId&gt;
              &lt;artifactId&gt;spring-android-rest-template&lt;/artifactId&gt;
              &lt;version&gt;${spring-android-version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;!-- Using Jackson for JSON marshaling --&gt;
              &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-mapper-asl&lt;/artifactId&gt;
              &lt;version&gt;${jackson-version}&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;repositories&gt;
          &lt;!-- For testing against latest Spring snapshots --&gt;
          &lt;repository&gt;
              &lt;id&gt;org.springframework.maven.snapshot&lt;/id&gt;
              &lt;name&gt;Spring Maven Snapshot Repository&lt;/name&gt;
              &lt;url&gt;http://maven.springframework.org/snapshot&lt;/url&gt;
              &lt;releases&gt;&lt;enabled&gt;false&lt;/enabled&gt;&lt;/releases&gt;
              &lt;snapshots&gt;&lt;enabled&gt;true&lt;/enabled&gt;&lt;/snapshots&gt;
          &lt;/repository&gt;
          &lt;!-- For developing against latest Spring milestones --&gt;
          &lt;repository&gt;
              &lt;id&gt;org.springframework.maven.milestone&lt;/id&gt;
              &lt;name&gt;Spring Maven Milestone Repository&lt;/name&gt;
              &lt;url&gt;http://maven.springframework.org/milestone&lt;/url&gt;
              &lt;snapshots&gt;&lt;enabled&gt;false&lt;/enabled&gt;&lt;/snapshots&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>And my android manifest file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="ae.test.android"
        android:versionCode="1"
        android:versionName="1.0"&gt;
      &lt;uses-sdk android:minSdkVersion="10" /&gt;
  
      &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
          &lt;activity android:name=".MainActivity"
                    android:label="@string/app_name"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>As far as I can tell, this should be a correct setup. The problem now is, when I try to build this project, I get:</p>
  
  <p>Cannot add source folder Duplicate files at the same path inside the APK</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/4923555/include-maven-dependencies-in-eclipse-run-as-android-application-build">this</a> on SO and while the solution (changing the default output folder of eclipse to <code>bin</code> instead of <code>target</code>) did solve the error, it didn't solve the dependency problem. My generated android files aren't included in the target folder so the solution is of no use to me.</p>
  
  <p>Has anyone else got any experience with setting up Android and Maven and if so, could you please help me out?</p>
  
  <p>Many thanks in advance!</p>