找不到方法maven()的解决方案

时间:2019-01-22 12:12:47

标签: android maven android-studio android-gradle build.gradle

Gradle项目同步失败

buildscript {
     repositories {
        jcenter()
                   }
                   dependencies {`


classpath 'com.android.tools.build:gradle:2.3.0'
    maven {
        url 'http://conjars.org/repo/'
        name 'Google'
        }
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }

  }
allprojects {
repositories {
    jcenter()
    mavenCentral()
    maven { url 'https://jitpack.io' }
    maven {
        url 'https://maven.google.com/'
        name 'Google'
        }
}
}

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

请帮助我解决此错误并同步我的gradle

错误消息:

  

在类型为org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler。的对象上找不到用于参数[build_c9dzq9rre1sc1dq0winaq8sc0 $ _run_closure1 $ _closure3 $ _closure4 @ 33323af1]的方法maven()。

2 个答案:

答案 0 :(得分:0)

替换为:

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'


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

allprojects {
    repositories {
        google()
        jcenter()

        maven { url 'https://jitpack.io' }

        maven {
            url 'https://maven.google.com/'
        }


    }
}

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

并确保您的互联网连接

答案 1 :(得分:0)

我也面临着同样的问题,幸运的是,花了几天的时间我才找到了解决方案。

allprojects {
    repositories {
        maven {
            url "http://packages.confluent.io/maven"
        }
    }
}

然后在依赖项中添加依赖项{}。