首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven拒绝从远程存储库下载aar打包依赖项。

Maven拒绝从远程存储库下载aar打包依赖项。
EN

Stack Overflow用户
提问于 2016-06-19 02:16:54
回答 4查看 5.8K关注 0票数 16

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

代码语言:javascript
复制
http://jcenter.bintray.com/com/o3dr/android/dronekit-android/2.9.0/

因此,我将所有插件和存储库添加到maven pom文件中:

代码语言:javascript
复制
<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>
        ...

然后将依赖项添加到同一个文件中:

代码语言:javascript
复制
    <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构建它,我会得到以下错误:

错误/home/peng/git-drone/dronespike/src/main/scala/Main.scala:1:对象o3dr不是软件包com的成员。 错误导入com.o3dr.android._ 误差^

问题:我该怎么做才能解决这个问题?

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2016-07-01 09:15:40

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

如果Maven不能下载工件,它会在构建生命周期中更快地抱怨。问题是,工件是下载的,但没有使用。aar不是一个标准的Maven工件,所以Maven不知道如何处理它。使用它需要一个带有扩展的第三方插件,因此使用android-maven-plugin。阅读它的文档,它有一些正常工作的要求。具体来说,您没有像这里提到的那样使用android打包:

支持的打包的使用: apk、aar或apklib

事实上,看看插件源代码,它在添加从aar到类路径的任何内容之前,都会检查安卓的打包情况。

票数 8
EN

Stack Overflow用户

发布于 2016-06-19 03:20:57

根据您的maven版本的需求,根据我之前遇到的情况,您可能需要添加用于发布和快照的配置。在我的例子中,一旦指定了这些参数,我就能够获得lib:

代码语言:javascript
复制
<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>

没有它,就不会下载依赖项。

票数 8
EN

Stack Overflow用户

发布于 2016-06-30 07:34:06

查看依赖项可用的装订盘存储库,并通过它的Set me up选项检查存储库设置,您的存储库坐标不正确,它们应该是:

代码语言:javascript
复制
<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>

实际上,有效的目标文件可以通过URL获得:

代码语言:javascript
复制
https://dl.bintray.com/3d-robotics/maven/com/o3dr/android/dronekit-android/2.9.0/

它尊重存储库URL加上它的Maven坐标(groupId、artifactId、version)。

还要注意:除非出于特定的原因,否则不要重用存储库id central,否则您将覆盖Maven构建的中心(默认)存储库,并且所有依赖项(和插件)只能由新声明的依赖项获取。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37903371

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档