0

I am building an Android game using LibGDX that needs to share achievements in Facebook. I followed this guide up to step 5. But when I tried step 6, I get an error on import com.facebook.FacebookSdk; saying it 'cannot be resolved'.

build.gradle content:

project(":android") {
apply plugin: "android"

configurations { natives }

dependencies {
    compile project(":core")
    compile "com.facebook.android:facebook-android-sdk:4.7.0"
    compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
    compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
    natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
    natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
    natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
}
}

I am using Android Studio version 1.4. I found a number of similar questions in StackOverflow but none of them worked for me. What am I doing wrong here? Any help would be much appreciated.

kasper360
  • 367
  • 2
  • 4
  • 14
  • Did you refresh your gradle dependencies? – TomGrill Games Oct 25 '15 at 09:25
  • @Thomas Pronold: If by refreshing you mean 'Syncing Project with Gradle Files', then yes I did. But it didn't do the trick. Could this be a problem with Facebook SDK build having an ".aar" format instead of the usual ".jar" format? – kasper360 Oct 25 '15 at 12:29
  • If you use Eclipse then the aar files don't work. You have 2 options then. (1) Switch to Android Studio or (2) open the aar file like a zip file. Extract the classes.jar. Rename it to facebook-sdk-4.7.0.jar. Include it to your project like a library. – TomGrill Games Oct 25 '15 at 14:01
  • @Thomas Pronold As I mentioned in the question, I am using Android Studio version 1.4, which I believe is the latest version. But still I get this error. Also, i found [this question](http://stackoverflow.com/questions/29826717/how-to-import-a-aar-file-into-android-studio-1-1-0-and-use-it-in-my-code). According to that I should downgrade my gradle version. I tried that but it gave me another set of errors. I'll try to extract the .jar and include it to see if it solves the problem. – kasper360 Oct 25 '15 at 14:08
  • No with AS you don't have to unpack the aar. Well I cannot help then, I do the same (code) within my projects and it just works. Only difference is that i use 4.6.0, but that should not be the problem – TomGrill Games Oct 25 '15 at 16:19

0 Answers0