Search code examples
androidmavendependenciesandroid-support-libraryandroid-maven-plugin

Extra dependency in my android maven dependency tree


I am trying to figure out why maven is adding this dependency:

 com.android.support:support-v4:jar:21.0.0:system

in my dependency tree. It is at the top level of the tree, not underneath any other dependencies which means that I should be able to locate it in the pom.xml? Well it's not there, or anywhere else in my project. It also doesn't exist under any of my other dependencies as a transitive dependency.

Running

mvn dependency:tree

with debug enabled only gives me these 2 extra lines :

[DEBUG]   testArtifact: artifact=com.android.support:support-v4:jar:21.0.0:system
[DEBUG]   includeArtifact: artifact=com.android.support:support-v4:jar:21.0.0:system

Any ideas ?

Edit: Is there any chance that the android-maven-plugin adds anything in my dependency tree ?


Solution

  • It's not coming from android-maven-plugin (AMP) but from an aar dependency. AMP is aware of how to process 'aar'. One of your android library (aar) has the support-v4 library as an internal jar (In other words it is contained in the aar inside the libs folder)

    Run mvn compile and the first couple of lines from mvn will show you a warning of which library include this jar.

    You have 2 choices:

    • ask the producer of that library to not provide the support-v4 within the aar but instead put a dependency in the build.gradle/pom.xml
    • never include any internal jars from aar's by setting the includeLibsJarsFromAar flag to false, but then you will face problem when you include the support-v4 lib yourself as it contains internal jars