3

I am new to libgdx on android studio. I am trying to integrate facebook with the android project. I am following this link(Getting Started) to integrate it with the android module. When I press sync I am supposed to be able to import com.facebook.FacebookSdk;

But it doesnt work that way.No matter what I try I get error cannot resolve symbol 'facebook'

In build.gradle of android module I have added:

repositories {
    mavenCentral()
}
dependencies {
    compile 'com.facebook.android:facebook-android-sdk:4.1.0'
    compile files('libs/twitter4j-core-4.0.4.jar')
    compile files(some adnetwork jars)
}

I also tried to add the compile 'com.facebook.android:facebook-android-sdk:4.1.0' in main build.gradle under project(":android") doesn't work either.

I tried syncing gradle several times, restarting android studio also File-> invalidatecaches/restart nothing seems to help.

Am I missing some step. Please advice.

Thanks

Aqvin
  • 85
  • 5

2 Answers2

1

I found the problem myself. I used cmd to build the project and what I found is that it failed because of "Unable to execute dex" problem (Too many methods) See here.

For people with similar problem in the future run this in your root project folder using cmd: gradlew build --stacktrace ` This will clearly give the reasons why the build had failed.

Community
  • 1
  • 1
Aqvin
  • 85
  • 5
0

Maybe you are adding it in the wrong place. In the root of you Libgdx Project open the build.gradle

add your line:

compile 'com.facebook.android:facebook-android-sdk:4.1.0'   

inside the dependencies in project(":android")

Rerun your build.gradle so it synchronizes and you should see:

Download https://repo1.maven.org/maven2/com/facebook/android/facebook-android-sdk/4.1.0/facebook-android-sdk-4.1.0.pom
Download https://repo1.maven.org/maven2/com/parse/bolts/bolts-android/1.2.0/bolts-android-1.2.0.pom
Download https://repo1.maven.org/maven2/com/parse/bolts/bolts-android/1.2.0/bolts-android-1.2.0.jar
Download https://repo1.maven.org/maven2/com/facebook/android/facebook-android-sdk/4.1.0/facebook-android-sdk-4.1.0.aar
João Costa
  • 412
  • 4
  • 15