Maven refuse to download aar packaged dependency from remote repository Maven refuse to download aar packaged dependency from remote repository android android

Maven refuse to download aar packaged dependency from remote repository


Use Android packaging, e.g. <packaging>apk</packaging>.

If Maven couldn't download the artifact, it would complain much sooner in the build lifecycle. The problem is that artifact is downloaded, but not used. aar is not a standard Maven artifact, so Maven doesn't know what to do with it. Using it requires a third party plugin with extensions, hence usage of android-maven-plugin. Reading its documentation, it has some requirements to work properly. Specifically you didn't use android packaging as mentioned here:

usage of a supported packaging: apk, aar or apklib

Indeed, looking at the plugin source code it checks for android packaging before adding anything from aar to classpath.


Depending on the requirement from your maven version, based on what I faced before, you might have the need to add the configuration for release and snapshot. In my case, I was just able to get the lib once I specified these parameters:

<repositories>    <repository>        <id>central</id>        <name>bintray-plugins</name>        <url>http://jcenter.bintray.com</url>        <releases>            <enabled>true</enabled>        </releases>        <snapshots>            <enabled>false</enabled>        </snapshots>    </repository></repositories><dependencies>    <dependency>        <groupId>com.o3dr.android</groupId>        <artifactId>dronekit-android</artifactId>        <version>2.9.0</version>        <type>aar</type>    </dependency></dependencies>

without it, the dependency was not downloaded.


Looking at the bintray repository from where the dependency is available, and check the repository settings via its Set me up option, your repositories coordinates are not correct, they should instead be:

<repositories>    <repository>        <snapshots>            <enabled>false</enabled>        </snapshots>        <id>bintray-3d-robotics-maven</id>        <name>bintray</name>        <url>http://dl.bintray.com/3d-robotics/maven</url>    </repository></repositories><pluginRepositories>    <pluginRepository>        <snapshots>            <enabled>false</enabled>        </snapshots>        <id>bintray-3d-robotics-maven</id>        <name>bintray-plugins</name>        <url>http://dl.bintray.com/3d-robotics/maven</url>    </pluginRepository></pluginRepositories>

And indeed the effective target file is available via the URL:

https://dl.bintray.com/3d-robotics/maven/com/o3dr/android/dronekit-android/2.9.0/

Which respects the repository URL plus its Maven coordinates (groupId, artifactId, version).


Also note: do not reuse the repository id central, unless for specific reason, otherwise you would override the central (default) repository of your Maven build and all of your dependencies (and plugins) would only be fetched by the newely declared one.