Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: package com.facebook.android does not exist in android studio project

I am new to android studio.I am developing an app which uses Facebook SDK.I have downloaded Facebbok SDK and imported it as a module to my android project.I am using latest version of android studio.So I simply imported it and did not make any change in other files for this.First I am trying to use facebook login functionality.But when I build the app I am getting following error.

     error: package com.facebook.android does not exist

I could see one solution as an answer to someone's question. But i could not understand it.Please somebody help me.

like image 200
andro-girl Avatar asked Sep 11 '14 07:09

andro-girl


4 Answers

check you build.gradle it should got this dependency

if you got library project:

dependencies {

    compile project(':facebook');

}

if you got jar files in libs folder:

dependencies {

    compile fileTree(include: ['*.jar'], dir: 'libs')

}

or just add maven central dependency to:

dependencies {
    compile 'com.github.asne.facebook:facebook:3.17.2'
}
like image 51
Olesia Avatar answered Nov 12 '22 18:11

Olesia


You need to add dependencies on your gradle file :-

compile 'com.facebook.android:facebook-android-sdk:4.1.0'

above is path you need to add dependencies {} like below :-

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.facebook.android:facebook-android-sdk:4.1.0'
}
like image 42
duggu Avatar answered Nov 12 '22 17:11

duggu


Is the facebook library is jar file or library project? If is jar file, you just need to add jar file in libs folder and dependencies { compile fileTree(dir: 'libs', include: '*.jar') } in build.gradle. If is library project, you should modify your setting.gradle and build.gradle files.

like image 43
Thinsky Avatar answered Nov 12 '22 19:11

Thinsky


Adding this line of code to the dependencies in the build.gradle file helped me get rid of the same error.

dependencies {
    ...
    compile 'com.facebook.android:facebook-android-sdk:4.0.0'
}

From platform=android facebook developers
-the last line of the section "Add Facebook SDK to Your Project")

like image 37
Timothy Steele Avatar answered Nov 12 '22 18:11

Timothy Steele