Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 {
        jcenter()
        mavenCentral()
    }
    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 {
        jcenter()
        //mavenCentral()
    }
}

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.

like image 663
Ibrahim Disouki Avatar asked Apr 11 '15 18:04

Ibrahim Disouki


People also ask

How can I update my Facebook SDK?

Select the App you want to upgrade (you might have access to multiple apps) Click Settings > Advanced. Select the latest version under the Upgrade API Version section for both “Upgrade All Calls” and “Upgrade Calls for App Roles”

What is Facebook SDK version?

This documentation describes how to integrate your Android app with Facebook to build engaging social apps by using the Facebook SDK for Android. To learn more about using Facebook development tools, see App Development. The current version of the Facebook SDK for Android is version 15.0.


2 Answers

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

like image 68
Ibrahim Disouki Avatar answered Nov 09 '22 01:11

Ibrahim Disouki


Actually i got the same problem and i solved it ..

1 : File > Import Module ..find facebook-android-sdk-4.0.1 then Finish

2 : Go to File > Project sturucture > dependecies tab > Module Dependencies select :facebook

3 : SYNC project and Rebuild

IF you got error like Could not find property 'ANDROID_BUILD_MIN_SDK_VERSION after rebuilding

go to facebook/build.gradle and change this part

compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
    buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION

    defaultConfig {
        minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
        targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
    }

to your sdk version like

 compileSdkVersion 21
        buildToolsVersion '21.1.1'

        defaultConfig {
            minSdkVersion 14
            targetSdkVersion 21
        }
like image 27
VLDCNDN Avatar answered Nov 09 '22 02:11

VLDCNDN