Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven refuse to download aar packaged dependency from remote repository

I want to use this android dependency in my java program:

http://jcenter.bintray.com/com/o3dr/android/dronekit-android/2.9.0/

so I added all the plugins & repositories into my maven pom file:

<repositories>
    <repository>
        <id>central</id>
        <name>bintray</name>
        <url>http://jcenter.bintray.com</url>
        <!--<snapshots>-->
            <!--<enabled>false</enabled>-->
        <!--</snapshots>-->
    </repository>
</repositories>

<pluginRepositories>
    <pluginRepository>
        <!--<snapshots>-->
            <!--<enabled>false</enabled>-->
        <!--</snapshots>-->
        <id>central</id>
        <name>bintray-plugins</name>
        <url>http://jcenter.bintray.com</url>
    </pluginRepository>
</pluginRepositories>

<build>
    <plugins>
        <plugin>
            <groupId>com.simpligility.maven.plugins</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <version>4.1.0</version>

            <extensions>true</extensions>
            <configuration>
                <sign>
                    <debug>false</debug>
                </sign>
            </configuration>
        </plugin>
        ...

Then I add the dependency into the same file:

    <dependency>
        <groupId>com.o3dr.android</groupId>
        <artifactId>dronekit-android</artifactId>
        <version>2.9.0</version>
        <type>aar</type>
    </dependency>

But nothing happens, maven ignore it as if it doesn't exist, if I import its main package in a scala file and build it with mvn clear install -U, I get this error:

[ERROR] /home/peng/git-drone/dronespike/src/main/scala/Main.scala:1: object o3dr is not a member of package com
[ERROR] import com.o3dr.android._
[ERROR] ^

Question: What should I do to fix this problem?

like image 902
tribbloid Avatar asked Jun 19 '16 02:06

tribbloid


People also ask

Why Maven dependencies are not getting downloaded?

If you run Maven and it fails to download your required dependencies it's likely to be caused by your local firewall & HTTP proxy configurations. See the Maven documentation for details of how to configure the HTTP proxy.

How do I force Maven to download dependencies?

We can use -U/--update-snapshots flag when building a maven project to force maven to download dependencies from the remote repository. Here, -U,--update-snapshots : Forces a check for missing releases and updated snapshots on remote repositories.

How do you upload packages built by Maven to remote repositories?

Navigate to your module project's generated build folder (e.g., /target ). You'll notice there is a newly generated JAR file. This is the artifact you'll deploy to your Nexus repository. Run Maven's deploy command to deploy your module project's artifact to your configured remote repository.


1 Answers

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.

like image 131
Anton Koscejev Avatar answered Oct 01 '22 13:10

Anton Koscejev