maven android 插件有错误(dependency=[android.support:compatibility-v7:apklib:19:compile] not found)

Posted

技术标签:

【中文标题】maven android 插件有错误(dependency=[android.support:compatibility-v7:apklib:19:compile] not found)【英文标题】:maven android plugin with error ( dependency=[android.support:compatibility-v7:apklib:19:compile] not found ) 【发布时间】:2013-12-15 21:12:15 【问题描述】:

我正在使用 Maven 3.1.1。 Eclipse Kepler 安装了 android-Configurator-for-M2E。

我的 POM.XML 看起来像:

<?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.company.sample</groupId>
    <artifactId>SampleApplication</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>SampleApplication</name>
    <description>A sample application to demo clean android code.</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <platform.version>2.3.1</platform.version>
        <android.plugin.version>3.6.0</android.plugin.version>
    </properties>

    <dependencies>
        <!-- android SDK -->
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>2.3.1</version>
            <scope>provided</scope>
        </dependency>

        <!-- support-v4 -->
        <dependency>
            <groupId>com.android.support</groupId>
            <artifactId>support-v4</artifactId>
            <version>19.0.0</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>com.google.android</groupId>
                    <artifactId>support-v4</artifactId>
                </exclusion>
            </exclusions>

        </dependency>

        <!-- v7-extra -->
        <dependency>
            <groupId>android.support</groupId>
            <artifactId>compatibility-v7</artifactId>
            <version>19</version>
            <type>apklib</type>
        </dependency>

        <dependency>
            <groupId>android.support</groupId>
            <artifactId>compatibility-v7</artifactId>
            <version>19</version>
            <type>jar</type>
        </dependency>

        <!-- v7-appcompat -->
        <dependency>
            <groupId>android.support</groupId>
            <artifactId>compatibility-v7-appcompat</artifactId>
            <version>19</version>
            <type>apklib</type>
        </dependency>

        <dependency>
            <groupId>android.support</groupId>
            <artifactId>compatibility-v7-appcompat</artifactId>
            <version>19</version>
            <type>jar</type>
        </dependency>

    </dependencies>
    <build>
        <finalName>$project.artifactId</finalName>
        <sourceDirectory>src</sourceDirectory>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>3.6.0</version>
                    <extensions>true</extensions>
                </plugin>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <configuration>
                        <sdk>
                            <platform>18</platform>
                        </sdk>
                        <action>
                            <ignore></ignore>
                        </action>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <configuration>
                    <sdk>
                        <path>$env.ANDROID_HOME</path>
                        <platform>18</platform>
                    </sdk>
                    <deleteConflictingFiles>true</deleteConflictingFiles>
                </configuration>
                <extensions>true</extensions>
            </plugin>

        </plugins>

    </build>

    <profiles>
        <profile>
            <id>allow-snapshots</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <repositories>
                <repository>
                    <id>snapshots-repo</id>
                    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
        </profile>
    </profiles>

</project>

命令:mvn clean install,构建成功,但是在eclipse中刷新项目报这个错误:

dependency=[android.support:compatibility-v7:apklib:19:compile] not found in workspace  pom.xml /SampleApplication  line 1  me.gladwell.eclipse.m2e.android.markers.dependency.apklib

【问题讨论】:

【参考方案1】:

通过下载 eclipse 4.3.1 的新副本并重新安装以下内容解决了这个问题:

    ADT 插件 M2E M2E-Android

然后导入构建良好的相同项目:mvn clean install。

然后从构建路径中删除所有库并执行:Android-Tools>Fix Project Properties。

【讨论】:

以上是关于maven android 插件有错误(dependency=[android.support:compatibility-v7:apklib:19:compile] not found)的主要内容,如果未能解决你的问题,请参考以下文章

错误:(2, 0) 在 android 中找不到 ID 为 'com.github.dcendents.android-maven' 的插件

maven中plugins和pluginmanagement的区别

maven pom xml文件中的错误:构建Android项目[重复]

具有变量的 maven 依赖项的 Ivy/sbt 错误,是不是有修复?

Maven组件插件无法执行问题,怎么解决

Android上传私有插件到私有MAVEN-PUBLISH