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.
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'
}
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'
}
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.
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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With