-1

I was unable to include the Facebook Android SDK in the normal way so I downloaded a jar and added it to Android Studio. For some strange reason I get an error Unresolved reference: FacebookSdk even though I can see the class in the Project view:

enter image description here

If I am doing the wrong thing can somebody please give a lucid explanation of how to download and use the Facebook SDK in Android Studio 3.

Edit

I need to use the Facebook SDK in my app and I need to download it and add it 'offline'.

halfer
  • 19,824
  • 17
  • 99
  • 186
Dave Chambers
  • 2,483
  • 2
  • 32
  • 55
  • I think it'll still compile. I have an app with the Samsung SDK loaded as a JAR, and the editor very rarely sees the classes available in that JAR, but the app compiles and runs just fine. I think it's a bug in Android Studio. – TheWanderer Sep 06 '18 at 15:39
  • @TheWanderer Thanks but no. The build fails. It seems that the Facebook SDK can't be added as a jar. – Dave Chambers Sep 06 '18 at 15:51
  • You did add it as a Gradle dependency right? You still need to manually specify JARs as dependencies. – TheWanderer Sep 06 '18 at 15:52
  • @TheWanderer No - how exactly do I do that? – Dave Chambers Sep 06 '18 at 15:53
  • https://stackoverflow.com/q/20700053/5496177 – TheWanderer Sep 06 '18 at 15:53
  • Whoops that won't help sorry. I'm on my phone right now. – TheWanderer Sep 06 '18 at 15:55
  • @TheWanderer - no problem and yes, it was added there when I added the module so I have `implementation files('libs/facebook-android-sdk-4.4.0-sources.jar')` – Dave Chambers Sep 06 '18 at 15:56
  • Any reason you have your target and build APIs on 26? It seems Facebook is using 27, so you may want to match that. – TheWanderer Sep 06 '18 at 15:59
  • @TheWanderer Yeah, I tried that but couldn't move to API 27. https://stackoverflow.com/q/52200705/1390035 Not a good day for me development wise :-( If you could answer that question it'd be great. – Dave Chambers Sep 06 '18 at 16:03
  • I read that question, and that's how I know you're using 26. Update to 27, change any 26 dependencies to. 27 (latest should be 27.1.1) and try compiling. – TheWanderer Sep 06 '18 at 16:12
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/179563/discussion-between-dave-chambers-and-thewanderer). – Dave Chambers Sep 06 '18 at 16:12

1 Answers1

0

this is the sources package (as it's filename may hint for), which is for reference only. you should possibly add a dependency to the build.gradle instead; it's from the mavenCentral() repository, you can also find the artifacts here ...and a whole lot of other Facebook SDKs here.

dependencies {
    implementation "com.facebook.android:facebook-android-sdk:4.36.0"
}

and also move those sources outside of the libs directory

(they still can be linked together with the fetched library).

Martin Zeitler
  • 1
  • 19
  • 155
  • 216