Could not find method maven()

Glenn Alex picture Glenn Alex · Jul 24, 2018 · Viewed 8.9k times · Source

I am getting the following error :

Could not find method maven() for arguments [build_3sdtqstdmsgdnexrxaaxgljji$_run_closure1$_closure4@325a800c] on root project 'Appointments' of type org.gradle.api.Project.

Here's my Project Level Gradle File:

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
}

And here's my app level 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'

I have tried all the techniques mentioned in other posts and solution website, but I dont find my same error listed in any of these websites. Hence I am creating this question here.

Answer

kemicofa ghost picture kemicofa ghost · Sep 26, 2018

You're getting this error because your maven shouldn't be a direct child of "allprojects" but a direct child of "repositories".

allprojects {
  repositories {
    google()
    jcenter()

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