简体   繁体   中英

Android studio error (17, 0) could not find method maven()

Project Gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    // ...
    dependencies {
        // ...
        classpath 'com.google.gms:google-services:3.1.0' // google-services plugin
    }
    repositories {
        google()
    }
}

allprojects {
    // ...
    dependencies {
        // ...
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }
    }
}

Module Gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '26.0.0'

    defaultConfig {
        applicationId "com.example.example"
        minSdkVersion 19
        targetSdkVersion 23

    }


    splits {
        abi {
            enable true
            reset()
            include 'x86', 'armeabi-v7a'
            universalApk true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.google.firebase:firebase-core:11.2.2'
    compile project(':rateMyApp')
    compile files('libs/android-async-http-1.4.6.jar')
    compile files('libs/com-uvxghdmx-ucuwreks167365.jar')
    compile files('libs/org.apache.http.legacy.jar')
    compile files('libs/universal-image-loader-1.9.3.jar')
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.balysv:material-ripple:1.0.2'
    compile 'com.google.android.gms:play-services-ads:11.2.2'
}
apply plugin: 'com.google.gms.google-services'

Getting Error

Error:(17, 0) Could not find method maven() for arguments [build_2rpdxydj6arlyq4m2v87kde3g$_run_closure1$_closure2$_closure3@70ca8e63] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Please Help Me...

You can work this one around like by adding the mavenCentral() to the repositories, then add the code to the repositories below the mavenCentral() line, and then resync:

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }
    }
}

this should remove the conflict with the sync.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM