-1

I am trying to use facebook SDK in my android apps, and I am starting to add maven central repository to my build.gardle. Although, I've found 2 build.gardle which belong to project and app. Here they are;

  • Android Studio: 1.5.1
  • Gradle Version: 2.8
  • Android Plugin Version: 1.5.0

Build.gardle (Project)

buildscript {
    repositories {
        jcenter()
        mavencentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
        compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    }
}

allprojects {
    repositories {
        jcenter()
        mavencentral()
    }
}

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

Build.gardle(app)

apply plugin: 'com.android.application'
android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.example.test"
        minSdkVersion 15
        targetSdkVersion 23
        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:23.2.0'
    compile 'com.android.support:design:23.2.0'
}

Yet I get this following error during build;

Gradle DSL method not found: mavencentral()

I have tried;

And, I haven't tried to update my gardle or android studio, but I am just wondering whether it's really needed or I am doing something wrong with my build.gardle.

Any suggestion is appreciated. Thank you.

Community
  • 1
  • 1
choz
  • 17,242
  • 4
  • 53
  • 73

1 Answers1

2

The Facebook SDK page is clear. Add into your project/build.gradle

repositories {
    mavenCentral() //note the uppercase C
}

and into your project/app/build.gradle

dependencies { 
  compile 'com.facebook.android:facebook-android-sdk:4.+'
}
xiaomi
  • 6,553
  • 3
  • 29
  • 34
  • Shit.. How can I miss that capital `C`.. But now I have another same issue which saying `Gradle DSL method not found: compile()`. Thanks btw.. – choz Feb 28 '16 at 05:29
  • 1
    because your compile the facebook sdk into the wrong gradle file ;) – xiaomi Feb 28 '16 at 05:33