7

I am stuck when trying to run my app with the FacebookSDK for Android included into my project in IntelliJ IDEA.

With a basic Android boilerplate, everything builds and runs fine. But as soon as I try to add the Facebook SDK to my project as explained in this post, I get multiple errors:

java: /Users/me/Projects/Android/facebook/src/com/facebook/widget/LoginButton.java:25: package android.support.v4.app does not exist

java: /Users/me/Projects/Android/facebook/src/com/facebook/widget/LoginButton.java:33:
cannot find symbol
symbol  : class R
location: package com.facebook.android

Project details

Detailed screenshots:

enter image description here

enter image description here

enter image description here

Why is that and how can I solve it?

Download: You can download the test project here.

Community
  • 1
  • 1
John B.
  • 2,309
  • 5
  • 23
  • 22

2 Answers2

6

The problem with your project is that the Facebook SDK module has the altered AndroidManifest.xml file that specifies the wrong package causing R.java file to be produced in a different package, hence the non-working imports.

Original AndroidManifest.xml file can be found here:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.facebook.android">
    <application/>
    <uses-sdk android:minSdkVersion="8" />
</manifest>

See also my answer regarding the proper android-support-v4.jar dependency configuration.

Community
  • 1
  • 1
CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • Perfect, thanks a lot :) Do you know why the `AndroidManifest.xml` gets modified (during my build process) or how I should include the Facebook SDK? I just found out that when I create an empty module as outlined [here](https://sites.google.com/site/beardadventures/articles/facebooktoandroidintegration) instead, everything seems to be working fine as well. – John B. May 10 '13 at 23:20
  • Probably it happens if you create a new module on top instead of importing. – CrazyCoder May 11 '13 at 05:30
  • Any other possible diagnoses? I have the exact same errors but my manifest xml file looks exactly the same as seen here. – Navneet Oct 22 '13 at 10:03
2

Android support v4 is the android support library. It backports some classes to older versions of the SDK. You can find the jar in your SDK, under extras. You need to include it in your project.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • Thanks, I have added `android-support-v4.jar` to my facebook library module. That solved the `android.support.v4` problem. But the problem with `com.facebook.android.R` still exists. Any ideas? – John B. May 09 '13 at 19:31
  • That seems like either the facebook project isn't built or isn't linked properly. Unfortunately I don't know IntelliJ so I can't help there. – Gabe Sechan May 09 '13 at 19:33
  • I think that the import of R from the facebook project is a simple error caused by an automatic import by the IDE. Just delete the import and add the correct one (the R of your project). – 5agado May 10 '13 at 16:46