首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >android-maven-plugin打包失败,存在分层项目和apklib依赖关系。

android-maven-plugin打包失败,存在分层项目和apklib依赖关系。
EN

Stack Overflow用户
提问于 2014-02-17 14:48:26
回答 1查看 341关注 0票数 0

我有一个主根项目,让我们把它称为一个包含所有模块列表和打包pom类型的pom.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>A</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>

<properties>
    <android.version>4.1.1.4</android.version>
    <android.target.version>17</android.target.version>
    <android.plugin.version>3.6.0</android.plugin.version>
    <android.roboelectric.version>2.2</android.roboelectric.version>
    <android.support.version.4>r7</android.support.version.4>
</properties>

<modules>
    <module>AA</module>
    <module>AB</module>
</modules>

这个项目有两个子项目,以免说AA和AB项目也带有poms。

项目AA是打包类型apklib,在编译安装方面也有nop问题,这是android-maven-plugin (android:apklib)。

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>com.example</groupId>
    <artifactId>A</artifactId>
    <version>0.0.1</version>
</parent>

<groupId>com.example</groupId>
<artifactId>AB</artifactId>
<packaging>apklib</packaging>

<build>
    <finalName>${project.artifactId}-${project.parent.version}</finalName>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>${android.plugin.version}</version>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </pluginManagement>
    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <configuration>
                <sdk>
                    <platform>17</platform>
                    <path>${env.ANDROID_HOME}</path>
                </sdk>
            </configuration>
        </plugin>
    </plugins>
</build>

项目AB对项目AA有依赖性,在pom中有如下所示

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>com.example</groupId>
    <artifactId>A</artifactId>
    <version>0.0.1</version>
</parent>

<groupId>com.example</groupId>
<artifactId>AB</artifactId>
<packaging>apklib</packaging>

<dependencies>
    <dependency>
        <groupId>com.examplet</groupId>
        <artifactId>AA</artifactId>
        <version>0.0.1</version>
        <type>apklib</type>
    </dependency>
</dependencies>

<build>
    <finalName>${project.artifactId}-${project.version}</finalName>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>${android.plugin.version}</version>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </pluginManagement>
    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <configuration>
                <sdk>
                    <platform>17</platform>
                </sdk>
            </configuration>
        </plugin>
    </plugins>
</build>

在打包过程中,甚至是android:apklib中,我都会遇到这样的错误

未能执行项目util:未能解决项目com.example.AB:apklib:0.0.1的依赖关系:未能为com.example.AA:apklib:0.0.1 (已提供)收集依赖关系:未能读取com.example.AA:apklib:0.0.1:未能在中央(http://repo.maven.apache.org/maven2) ->帮助1中找到工件示例:a:pom:0.0.1

我已经在项目AA上运行了mvn安装,并且看起来它是安装在.m2中的

有什么想法吗?提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-17 15:00:02

好的,我解决了这个问题,问题是我在没有安装它的情况下改变了根pom,所以我只是在根项目上再次运行mvn安装,这解决了这个问题。

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

https://stackoverflow.com/questions/21832086

复制
相关文章

相似问题

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