Android Studio Gradle: Error: Configuration named 'compile' not found

My project failed with error below gradle script: Error: Configuration named 'compile' not found.

// Top level build file where you can add configuration options common to all subprojects / modules.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.2'
        classpath 'com.google.gms:google-services:3.1.0'

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

allprojects {
    repositories {
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
apply plugin: 'com.google.gms.google-services'

      

+3


source to share


3 answers


Remove plugin: com.google.gms.google-services from project /build.gradle and put it in your app / build.gradle file



apply plugin: 'com.android.application'
android {

...
..
}

dependencies {

....
..

}

apply plugin: 'com.google.gms.google-services'

      

+9


source


paste apply plugin: "com.google.gms.google-services" at the bottom of build.gradle (module app) and compile 'com.google.firebase: firebase-core: 12.0.0' depending on build.graddle (module app)



remove plugin: "com.google.gms.google-services" from build.gradle (project name)

0


source


I am facing the same error, I solved it by deleting .each{...}

and moving it to the bottom dependencies {...}

with a prefix implementation

:

apply plugin: 'com.android.application'

buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
        google()
        flatDir {
            dirs '<your_aar_directory_patj>'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0-alpha12'
    }

    //[1] Don't put here !!!
}

...

//[2] Remove the below ".each{...}" part, then put it inside dependencies with prefix 'implementation':
/*
fileTree(dir: 'your_aar_directory_path', include: '**/*.aar')
.each { File file ->
dependencies.add("compile",
[name: file.name.lastIndexOf('.').with {
it != -1 ? file.name[0..<it] : file.name
}, ext: 'aar'])
}
*/

dependencies {
    implementation fileTree(dir: '<your_aar_directory_path>', include: '**/*.aar')
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    ...
}

      

implementation fileTree(dir: '<your_aar_directory_path>', include: '**/*.aar')

suppresses the error. The documentation I'm linking to seems to be outdated.

0


source







All Articles