0

I'm trying to add Facebook dependency to my project.

I tried adding the following to my pom.xml:

    <dependency>
        <groupId>com.facebook.android</groupId>
        <artifactId>facebook-android-sdk</artifactId>
        <version>4.1.0</version>
        <type>aar</type>
    </dependency>

And suddenly none of the previously accepted dependencies is found:

enter image description here

When I exclude support-v4 library

    <dependency>
        <groupId>com.facebook.android</groupId>
        <artifactId>facebook-android-sdk</artifactId>
        <version>4.1.0</version>
        <type>aar</type>
        <exclusions>
            <exclusion>
                <artifactId>support-v4</artifactId>
                <groupId>com.android.support</groupId>
            </exclusion>
        </exclusions>
    </dependency>

I don't have as many errors,

enter image description here

but it does not seem to include my dependency:

enter image description here

Is there anything I'm missing there?

Here's my build :

<build>
    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <version>${android.maven.version}</version> <!-- 4.0.0-rc.2 -->
            <goals>
                <goal>consume-aar</goal>
            </goals>
            <extensions>true</extensions>
            <configuration>
                <sdk>
                    <platform>${platform.version}</platform> <!-- 4.3 -->
                </sdk>
                <deleteConflictingFiles>true</deleteConflictingFiles>
                <undeployBeforeDeploy>true</undeployBeforeDeploy>
            </configuration>
        </plugin>
    </plugins>
</build>

--- EDIT ----

The dependency tree seems fine:

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ konnect-android ---
[INFO] com.company:project-android:apk:1.0.0
[INFO] +- com.company:project-shared:jar:1.0.0:compile
[INFO] +- com.google.android:android:jar:4.1.1.4:provided
[INFO] |  +- commons-logging:commons-logging:jar:1.1.1:provided
[INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.0.1:provided
[INFO] |  |  +- org.apache.httpcomponents:httpcore:jar:4.0.1:provided
[INFO] |  |  \- commons-codec:commons-codec:jar:1.3:provided
[INFO] |  +- org.khronos:opengl-api:jar:gl1.1-android-2.1_r1:provided
[INFO] |  +- xerces:xmlParserAPIs:jar:2.6.2:provided
[INFO] |  \- xpp3:xpp3:jar:1.1.4c:provided
[INFO] +- com.marvinlabs:android-slideshow-widget:jar:0.5.0:compile
[INFO] +- com.marvinlabs:android-slideshow-widget-picasso-    plugin:jar:0.5.0:compile
[INFO] +- com.squareup.okhttp:okhttp:jar:2.3.0:compile
[INFO] |  \- com.squareup.okio:okio:jar:1.3.0:compile
[INFO] +- com.squareup.okhttp:okhttp-urlconnection:jar:2.3.0:compile
[INFO] +- com.squareup.picasso:picasso:jar:2.5.2:compile
[INFO] +- com.parse.bolts:bolts-android:jar:1.2.0:compile
[INFO] +- com.facebook.android:facebook-android-sdk:aar:4.1.0:compile
[INFO] +- junit:junit:jar:4.11:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] \- com.facebook.android:facebook-android-sdk:jar:4.1.0:system
Majid Laissi
  • 19,188
  • 19
  • 68
  • 105
  • Perhaps you need to add a `reposytory` too. – Tiberiu C. Jun 01 '15 at 20:53
  • which one? it does not complain about facebook (which is in the maven central).. – Majid Laissi Jun 01 '15 at 20:54
  • 1
    I am not sure, analyze with `mvn dependency:tree` – Tiberiu C. Jun 01 '15 at 21:00
  • the question is do you want to use `facebook-android-sdk` artefact without the android libraries? otherwise you most likely want to check this : https://github.com/simpligility/maven-android-sdk-deployer according to this stack: http://stackoverflow.com/questions/18380337/android-support-library-setup-with-maven – Tiberiu C. Jun 01 '15 at 21:08
  • thank you again for your help, I just added the dependency tree, which seems fine :-/ – Majid Laissi Jun 01 '15 at 21:08
  • I just want to include Facebook to my project, any method would do.. – Majid Laissi Jun 01 '15 at 21:14
  • I'm pretty sure that it won't work without the `com.android.support:support-v4`, even if you manage to fix the pom config, because it may have direct class imports to it, otherwise they wouldn't specify it as a dependency. Maybe this lib is better suited for your needs : http://projects.spring.io/spring-social-facebook/ – Tiberiu C. Jun 01 '15 at 21:21
  • Thanks, but this seemes more like a webserver library though will lots of spring libraries.. – Majid Laissi Jun 01 '15 at 22:35

1 Answers1

0
compile 'com.facebook.android:facebook-android-sdk:[4,5)' 

1. Go to Android Studio | New Project | Minimum SDK
2. Select "API 15: Android 4.0.3" or higher and create your new project.
3. In your project, open
your_app | Gradle Scripts | build.gradle
4. Add the Maven Central Repository to build.gradle before dependencies:
repositories {
        mavenCentral()
    }
5. Add compile 'com.facebook.android:facebook-android-sdk:[4,5)' to your build.gradle dependencies.
6. Build your project.
7. Import Facebook SDK into your app:
import com.facebook.FacebookSdk;
Keshav Gera
  • 10,807
  • 1
  • 75
  • 53