找不到方法maven()

时间:2018-07-24 08:24:07

标签: android maven android-gradle crashlytics firebase-crash-reporting

我遇到以下错误:

在根项目“约会”类型为org.gradle.api.Project的参数[build_3sdtqstdmsgdnexrxaaxgljji $ _run_closure1 $ _closure4 @ 325a800c]中找不到方法maven()。

这是我的项目级别Gradle文件:

buildscript {

repositories {
    google()
    jcenter()
    maven { url "http://jcenter.bintray.com"}
    maven { url "https://maven.fabric.io/public" }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
    classpath 'com.google.gms:google-services:4.0.0'
    classpath 'io.fabric.tools:gradle:1.25.4'


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

allprojects {
repositories {
    google()
    jcenter()
}
maven {
    url 'https://maven.google.com/'
}
}

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

这是我的应用程序级别Gradle File:

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
    applicationId "com.gtaandteam.android.wellcure"
    minSdkVersion 19
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
 }
}

repositories {
mavenCentral()
maven {
    url "https://s3-ap-southeast-1.amazonaws.com/godel-release/godel/"
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'ai.devsupport.instamojo:instamojolib:0.1.6'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-crash:11.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation "com.android.support:design:24.2.0"
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.3'


}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'

我已经尝试了其他帖子和解决方案网站中提到的所有技术,但在这些网站中都找不到相同的错误。因此,我在这里创建这个问题。

1 个答案:

答案 0 :(得分:4)

您收到此错误消息是因为您的maven不应是“ allprojects”的直接子代,而应是“ repository”的直接子代。

allprojects {
  repositories {
    google()
    jcenter()

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