Android Studio Gradle: Error: Configuration with Name 'Compile' Not Found
My Project Refresh Is Failing with the Error for the Below Gradle Script: Error: Configuration with Name 'Compile' Not Found. // Top-Level Build File Where You...
My project refresh is failing with the error for the below gradle script: Error:Configuration with name 'compile' not found.
// Top-level build file where you can add configuration options common to all sub-projects/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'
2 Answers
Remove apply plugin: 'com.google.gms.google-services' from project/build.gradle and put it in your app/build.gradle
apply plugin: 'com.android.application'
android {
...
..
}
dependencies {
....
..
}
apply plugin: 'com.google.gms.google-services'
I face the same error, I solved it by removed the .each{...} and move it into bottom dependencies {...} with prefix implementation:
apply plugin: 'com.android.application'
buildscript {
repositories {
jcenter()
maven { url ' }
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'
...
}
The implementation fileTree(dir: '<your_aar_directory_path>', include: '**/*.aar') suppress the error. The documentation I refer to seems obsolete.