Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't run with Facebook SDK included

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.

like image 474
John B. Avatar asked May 09 '13 19:05

John B.


People also ask

How do I know if Facebook SDK is installed?

First, go to your Analytics for Apps page: Analytics for Apps. Then, click "Mobile App Installs” from the left-hand navigation, and check your last install reported to confirm proper installation of the SDK.

Is Facebook SDK free?

The Graph API is free to use, for all applicable use cases.


2 Answers

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.

like image 183
CrazyCoder Avatar answered Sep 21 '22 13:09

CrazyCoder


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.

like image 25
Gabe Sechan Avatar answered Sep 21 '22 13:09

Gabe Sechan