Eclipse的android项目项目与facebook sdk作为maven依赖

时间:2015-09-17 10:40:57

标签: android eclipse facebook maven

我想在我的Eclipse项目中使用Facebook Android SDK作为Maven依赖项。将依赖项添加到pom.xml后,我收到错误:

  

无法在项目test-client-android上执行目标:无法解析项目com.test.:test-client-android:apk:0.1.0的依赖项:未能找到com.facebook.android:facebook-android -sdk:jar:https://repo.maven.apache.org/maven2中的4.6.0被缓存在本地存储库中,在中心的更新间隔过去或强制更新之前,不会重新尝试解析

下面是我的pom.xml文件。我试过做maven更新,但没有任何改变。有什么问题?

<?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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>test-client-android</artifactId>
<version>0.1.0</version>
<packaging>apk</packaging>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>4.1.1.4</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.android.support</groupId>
        <artifactId>support-v4</artifactId>
        <version>23.0.1</version>
        <scope>system</scope>
        <systemPath>${env.ANDROID_HOME}/extras/android/support/v4/android-support-v4.jar</systemPath>
    </dependency>

    <dependency>
        <groupId>com.mcxiaoke.volley</groupId>
        <artifactId>library</artifactId>
        <version>1.0.19</version>
    </dependency>

    <dependency>
        <groupId>com.facebook.android</groupId>
        <artifactId>facebook-android-sdk</artifactId>
        <version>4.6.0</version>
    </dependency> 
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>com.simpligility.maven.plugins</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <version>4.3.0</version>
            <configuration>
                <sdk>
                    <platform>23</platform>
                </sdk>
                <deleteConflictingFiles>true</deleteConflictingFiles>
                <undeployBeforeDeploy>true</undeployBeforeDeploy>
            </configuration>
            <extensions>true</extensions>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>

1 个答案:

答案 0 :(得分:0)

我认为异常是由于android支持库。 facebook也使用android.support库,所以只需从facebook依赖项中排除android.support依赖项,如下所示。

<dependency>
        <groupId>fr.avianey</groupId>
        <artifactId>facebook-android-api</artifactId>
        <version>3.18.0</version>
        <type>jar</type>
        <exclusions>
          <exclusion>
            <artifactId>support-v4</artifactId>
            <groupId>com.google.android</groupId>
          </exclusion>
        </exclusions>
      </dependency>