2016-07-31 91 views
0

我想添加Facebook登录。我正在关注facebook quick starts。但是我收到以下错误。Facebook集成在android给compile()错误

`

Error:(24, 0) Gradle DSL method not found: 'compile()' 
Possible causes:<ul><li>The project 'FacebookAdd' may be using a version of Gradle that does not contain the method. 
<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin. 
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>` 

gradle.build文件。

// 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:2.1.2' 

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

allprojects { 
    repositories { 
     jcenter() 
     mavenCentral() 
    } 
} 

dependencies { 
    compile 'com.facebook.android:facebook-android-sdk:[4,5)' 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 24 
    buildToolsVersion "24.0.0" 

    defaultConfig { 
     applicationId "com.psycho.ayush.facebookadd" 
     minSdkVersion 17 
     targetSdkVersion 24 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

    dependencies { 
     compile fileTree(dir: 'libs', include: ['*.jar']) 
     testCompile 'junit:junit:4.12' 
     compile 'com.android.support:appcompat-v7:24.1.1' 
    } 

P.S.我在这个网站上几乎浏览了与此有关的所有问题。

回答

0

它看起来像你有两个依赖部分,请试试这个:

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:24.1.1' 
    compile 'com.facebook.android:facebook-android-sdk:[4,5)' 
    } 

,并删除该

dependencies { 
compile 'com.facebook.android:facebook-android-sdk:[4,5)'}