Maven拒绝从远程存储库下载aar打包的依赖项 [英] Maven refuse to download aar packaged dependency from remote repository

查看:134
本文介绍了Maven拒绝从远程存储库下载aar打包的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的java程序中使用这个android依赖项:

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

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

所以我添加了所有插件&存储库到我的maven pom文件中:

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>

但是没有任何反应,maven会忽略它,好像它不存在一样.如果我将其主程序包导入scala文件并使用mvn clear install -U进行构建,则会出现此错误:

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:

[错误]/home/peng/git-drone/dronespike/src/main/scala/Main.scala:1:对象o3dr不是com包的成员
[错误]导入com.o3dr.android._
[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] ^

问题:如何解决此问题?

推荐答案

使用Android包装,例如<packaging>apk</packaging>.

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

如果Maven无法下载工件,它将在构建生命周期中更快地提出投诉.问题是工件已下载但未使用. aar不是标准的Maven工件,因此Maven不知道如何处理它.使用它需要带有扩展名的第三方插件,因此使用android-maven-plugin.阅读其文档,它对正常工作有一些要求.具体来说,您没有使用此处提到的android包装:

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:

支持的包装的用法:apk,aar或apklib

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.

这篇关于Maven拒绝从远程存储库下载aar打包的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆