将Facebook SDK导入我的android项目 - Gradle错误

mar*_*375 3 android facebook intellij-idea android-gradle-plugin facebook-sdk-3.1

我有一个问题,让我在过去几天忙,我想得到一些帮助......

我正在使用intellij 13.1.3,当我尝试将Facebook SDK添加为模块时,我收到一个错误

错误:Gradle:错误:包com.facebook不存在

我完全按照@Scott Barta在这里解释的那样做了一切:https://stackoverflow.com/a/20221453/1018192

请帮我!:( 非常非常感谢你 :)

编辑1: 我的build.gradle文件:

facebook - > build.gradle

apply plugin: 'android-library'

dependencies {
    compile 'com.android.support:support-v4:13.0.+'
    compile files('libs/bolts.jar')
}

android {
    compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
    buildToolsVersion "19.0.0"

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

    lintOptions {
        abortOnError false
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

my_proj - > build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19.1.0'
    compile 'com.android.support:support-v4:19.1.0'
}
Run Code Online (Sandbox Code Playgroud)

My_proj - > build.gradle

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

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}
Run Code Online (Sandbox Code Playgroud)

My_proj - > settings.gradle

include ':my_proj'
include ':libraries:facebook'
Run Code Online (Sandbox Code Playgroud)

小智 5

只需将其添加为依赖项

    dependencies {
        compile 'com.facebook.android:facebook-android-sdk:3.22.0'
    }
Run Code Online (Sandbox Code Playgroud)

使用http://gradleplease.appspot.com/#facebook获取最新版本