android - 找不到Android Studio Gradle DSL方法: 'mavencentral()'

标签 android maven android-studio gradle android-gradle-plugin

我正在尝试在Android应用程序中使用facebook SDK,并且开始将Maven中央存储库添加到build.gardle。虽然,我发现2 build.gardle属于项目和应用程序。他们来了;

  • Android Studio: 1.5.1
  • Gradle版本: 2.8
  • Android插件版本: 1.5.0

  • 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()



    我努力了;
  • Checking both gardle files
  • Removing android compile dependencies that's actually should be there
  • Checking android packagingOptions.exclude
  • Checking if there's android method in the gardle

  • 而且,我没有尝试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/

    相关文章:

    android - 为什么不能直接访问本地服务?

    java - Image() 已经在使用 Lombok 的 Maven 构建期间在类中定义

    java - Spring Boot - org.springframework.beans.factory.BeanCreationException : Error creating bean with name

    java - Intent 为空

    android - 每个 fragment 中的不同颜色状态栏

    android - 带有 Cordova 的 Braintree 用于在应用程序中购买以进行功能升级

    java - 如何在android中检查电子邮件格式是否有效

    maven-2 - maven3 运行时可以执行 maven2 兼容的 pom.xml 文件吗

    android - Cordova 构建到 Android 错误

    android - java.lang.NoSuchMethodError : No static method getDrawable(Landroid/content/Context;I)Landroid/graphics/drawable/Drawable; 错误