How can I add the facebook sdk to my android project in IntelliJ? I'm familiar with how to add a library project to an existing project in Eclipse, but not in IntelliJ. Anyone know how?
2 Answers
The answer below is outdated, please refer to the actual solution.
If it's just a jar, you can add it to the module dependencies.
If you want to use Android Library with source code, you need to create a new Module in IDEA with Android Facet and specify in the facet settings that it's Android Library Project. Configure module content and source roots and then add this module as a dependency to your Android application module.
Here are the screenshots for the Facebook SDK Android Module configuration in IDEA:
Note that the root of the module is set to the facebook subdirectory from the GitHub repository and Is Library Project checkbox is enabled.
If you add this module as a dependency to your application, everything should build fine.
I've also uploaded a sample project that consists of simple sample provided with the SDK and this facebook API module as a dependency, you can download and use it for reference.

- 1
- 1

- 389,263
- 172
- 990
- 904
-
thanks a lot. If I create a module from scratch and then point to the fb sdk, do I choose "application" or "project" under "Project Properties"? – LuxuryMode Aug 31 '11 at 19:43
-
So I used "project" and everything seemed fine. Except when I tried to build ;) I'm getting the error that "directory libraries are not supported". also, it's not a jar. I downloaded the project from github. – LuxuryMode Aug 31 '11 at 20:17
-
Thanks a lot. Still can't get this to work correctly. I need to create a separate project first from the SDK project and then add it? – LuxuryMode Sep 01 '11 at 01:42
-
I created a new project from the SDK. Then I created a new module from existing iml. Then I went to project structure and added it as a module dependency, but it's still not working. – LuxuryMode Sep 01 '11 at 01:50
-
Ok, finally got it to work. When I created the new project, I accidentally selected the root sdk folder, instead of the "facebook" subfolder. But intellij is saying that it cant find "symbol facebook_icon in fbdialog.java" even though no error shows up in that class. Only a problem when I try building... – LuxuryMode Sep 01 '11 at 01:57
-
Resource values in red appears to be a bug in IDEA which we'll investigate. The project builds fine. – CrazyCoder Sep 01 '11 at 09:09
-
The code that references this resource does not itself have any error hightlighting. Only shows up when I try building. So far, there are two bugs that are making it very annoying to use IDEA. "clip" is invalid as an element inside xml and now this. Hopefully it'll all get resolved sooner than later because, overall, I love IDEA and would hate to be forced back to Eclipse. – LuxuryMode Sep 01 '11 at 16:47
-
There is linked zip project in my answer that builds fine on my machine with IDEA 10.5.1. – CrazyCoder Sep 01 '11 at 16:55
-
Here is the bug for the R resolve problem: http://youtrack.jetbrains.net/issue/IDEA-66815. – CrazyCoder Sep 06 '11 at 11:16
-
1Crazy coder, I have followed your instructions, but in my project using intellij 12 it won't work. It fails to find resources that I use from the Facebook SDK library. Im at a loss because every tutorial seems to point to this one anyways. – Andy Jun 16 '13 at 17:30
-
I couldn't get it to work as an imported module, bringing in the SDK. But associating the dependency to the JAR as a library worked great (as this answer says). My issue was repeat references to the support library, and no scope combination of runtime/compiled would work. To import as library: on Dependencies tab, click "+" and find the compiled FacebookSDK.jar. – Anna Billstrom Sep 29 '14 at 20:54
Remove if inappropriate - but this solution was much more relevant for the latest version of IDEA and the latest Facebook SDK: https://stackoverflow.com/a/14732898/1711200
Tested with IDEA 12.1.2 and Facebook SDK 3.0.1
My reason for posting this is because the directory structure for the latest Facebook SDK is different & makes this post outdated. I also kept getting directed to this thread, whereas the thread I've linked to is a better & more relevant solution.