我正在尝试在Android应用程序中使用facebook SDK,并且开始将Maven中央存储库添加到build.gardle
。虽然,我发现2 build.gardle
属于项目和应用程序。他们来了;
Build.gardle(项目)
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'
}
但是我在构建过程中遇到了以下错误;
Gradle DSL method not found: mavencentral()
我努力了;
packagingOptions.exclude
而且,我没有尝试update my gardle or android studio,但是我只是想知道它是否真的需要,或者我的
build.gardle
做错了什么。任何建议表示赞赏。谢谢。
最佳答案
Facebook SDK page很清楚。添加到您的项目/ build.gradle
repositories {
mavenCentral() //note the uppercase C
}
并进入您的project / app / build.gradle
dependencies {
compile 'com.facebook.android:facebook-android-sdk:4.+'
}
关于android - 找不到Android Studio Gradle DSL方法: 'mavencentral()',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35678872/