hema18 hema18 - 6 months ago 59
Android Question

Can not import facebook-sdk 4.0.1

I have android studio 1.1.0 and i just created a new project and i'm trying to import new facebook-sdk 4.0.1 but can not do this, I followed Facebook Getting Started

But can not get it work. My app structure enter image description here

My build.gradle(Project: MyApplication) file is:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

allprojects {
repositories {

My build.gradle(Module: app) file is:

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "21.1.2"

defaultConfig {
applicationId "com.example.hema.myapplication"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.facebook.android:facebook-android-sdk:4.0.1'

Finally the error message is:

Error:(28, 13) Failed to resolve: com.facebook.android:facebook-android-sdk:4.0.1
<a href="openFile">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

Edit I added mavenCentral() in the repositories closure in build.gradle(Project: MyApplication) file but not working with same error message.


I solved the problem, It was in my Gradle settings >> Unchecked Offline work enter image description here