[android] Android Studio Gradle Configuration with name 'default' not found

I am having problems compiling my app with Android Studio (0.1.5). The app uses 2 libraries which I have included as follows:

settings.gradle

include ':myapp',':library',':android-ColorPickerPreference'

build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android'

dependencies {
    compile files('libs/android-support-v4.jar')
    compile project(':library')
    compile project(':android-ColorPickerPreference')

}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 16
    }
}

When compiling I get this message:

  Gradle: A problem occurred configuring project ':myapp'.
   > Failed to notify project evaluation listener.
   > Configuration with name 'default' not found.

Could you help me with this message? Thanks!

This question is related to android gradle android-studio

The answer is


I recently encountered this error when I refereneced a project that was initiliazed via a git submodule.

I ended up finding out that the root build.gradle file of the submodule (a java project) did not have the java plugin applied at the root level.

It only had

apply plugin: 'idea'

I added the java plugin:

apply plugin: 'idea'
apply plugin: 'java'

Once I applied the java plugin the 'default not found' message disappeared and the build succeeded.


I solved this issue by fixing some paths in settings.gradle as shown below:

include ':project-external-module'

project(':project-external-module').projectDir = file('/project/wrong/path')

I was including an external module to my project and had the wrong path for it.


One other potential cause of this precise error: I found this error was resolved by commenting some unused libraries in build.gradle dependencies section. Make sure these paths and such are all correct.

I'd look real close at your compile project(':android-ColorPickerPreference') entry in the build.gradle - try commenting out the related code and this line in build.gradle and see if that compiles - then go from there resolving the path or library issue.


I had this issue when I manually pasted google-play-services_lib into my project. Obviously, play-services didn't have a build.gradle file in it. The solution, I learned, is to put this dependency in my project's build.gradle (instead of hard-copying the play-services directory):

    compile 'com.google.android.gms:play-services:4.0.+'

Also... check if you have the module files inside your project.

For example, I have an app which uses the Volley module. During my studies on Android development, I accidentally removed the files which were inside the "volley" directory..

~/git/Sandbox/android/HelloWorld/volley $ ll
total 8
drwxrwxr-x 2 ivanleon ivanleon 4096 Jun 16 22:26 ./
drwxrwxr-x 6 ivanleon ivanleon 4096 Jun 17 01:51 ../

I just cloned the project (see bellow) and then, I made the Sync of the project at Android Studio (Tools > Android > Sync Project with Gradle Files), and Gradle build finished normally (Gradle Console: bottom right corner of Android Studio) ;).

~/git/Sandbox/android/HelloWorld/volley $ git clone https://android.googlesource.com/platform/frameworks/volley
Cloning into 'volley'...
remote: Counting objects: 164, done
remote: Finding sources: 100% (164/164)
remote: Total 3222 (delta 307), reused 3222 (delta 307)
Receiving objects: 100% (3222/3222), 1.22 MiB | 114.00 KiB/s, done.
Resolving deltas: 100% (307/307), done.
Checking connectivity... done.

~/git/Sandbox/android/AndroidGetJSON $ ls volley
Android.mk      build         build.xml         pom.xml       
proguard-project.txt      src    bintray.gradle  build.gradle
custom_rules.xml  proguard.cfg  rules.gradle          volley.iml

In my case I received this error when I misspelled the module name of the library (dependency) in build.gradle file.

So remember to check if the name of the module is correct.

build.gradle

dependencies {
    compile project(':module-name-of-the-library')
}

The following procedure solved my issue:

  • Go to your sub-project-module/library-module settings. (press F4 after selecting the module)
  • Right Click on Add > Android-Gradle.
  • Add build.gradle to your module.
  • Add the following script

    buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
     }
    
    
      apply plugin: 'android-library'
    
    repositories {
    mavenCentral()
    }
    
    android {
    compileSdkVersion 18
    buildToolsVersion "18.1.0"
    
    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 18
    }
    
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
    
    }
       } 
    
    1. add include ':yourModuleName' in your settings.gradle

In my case, after compiling with gradle tasks --info, the log was there :

Evaluating project ':libraries:VolleyLibrary' using empty build file.

So it failed to find build.gradle file of the library. Reason is the folder structure.

It was

-libraries
--volley
---VolleyLibrary

It is supposed to be

-libraries
--VolleyLibrary

I forgot to pull all submodules. So my

compile project(':something')

could not be resolved.

Solution

git submodule update --init

compile fileTree(dir: '//you libraries location//', include: ['android-ColorPickerPreference'])

Use above line in your app's gradle file instead of

compile project(':android-ColorPickerPreference')

Hope it helps


This happens when you are compiling imported or copied folder/project as module in libraries folder. This issue was raising when I did not include the build.gradle file. when I added the file all went just fine.


In my case I was using Gradle files that work under Windows but failed on Linux. The include ':SomeProject' and compile project(':SomeProject') were case sensitive and were not found.


I had a git submodule problem when getting this error. Try running gradle tasks --info for a more detailed problem description. I first used gradle tasks --debug, which was not nearly as helpful as --info.


When i import my library manually i had same issue. I tried to add my library with file > import module and it solved my issue.


For me folder was missing which was declared under settings.gradle.


Everything looks fine at first blush, but some poking around on here found an answer that could be helpful: https://stackoverflow.com/a/16905808/7944

Even the original answer writer doesn't sound super confident, but it's worth following up on. Also, you didn't say anything about your directory structure and so I'm assuming it's boring default stuff, but can't know for sure.


I've also faced with this error - I forgot to create build.gradle script for library project.


Suppose you want to add a library (for example MyLib) to your project, You should follow these steps:

  1. Prepare your library as a gradle Android library if your library's type is Eclipse ADT
    For this job it's enough to import it in Android Studio
  2. Copy your library folder, in this case MyLib folder, and paste it in your main project folder. It's a good practice to create a new folder in your main project folder and name it Libraries
  3. Go to Android Studio and open Settings.gradle file, there you should include your library in your main project. For example include ':MyPrj', 'Libraries:MyLib'. Note: Current directory for this include statement is your main project folder. If you paste your project into a folder you must mention it's address relative to the main project directory. In my case I paste MyLib into Libraries folder. This Libraries name is not a keyword and you can choose other names for it
  4. Open your Project Structure page(File->Project Structure...) click on modules then click on your main project go to dependencies tab click on + then choose Module dependency and there is your libraries and you can select them as you want

Hope it help


Try adding Volley library and sync and run the program. if one has pulled and i has volley usage and the error shows as -Android Studio Gradle Configuration with name 'default' not found then follow the step of adding the volley library in your gradle. hope it helps. I cleared my problem this way.


Your build.gradle for the module/library could be as simple as:

apply plugin: 'java'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

If your module is just a collection of .java POJO classes.

If it's model / entity classes and you're using annotations and have some dependencies you could add those in:

apply plugin: 'java'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.j256.ormlite:ormlite-core:4.48'
    compile 'com.j256.ormlite:ormlite-android:4.48'
    compile 'com.j256.ormlite:ormlite-jdbc:4.48'
}

For me it turned out to be an relative symbolic link (to the referenced project) that couldn't be used by grade. (I was referencing a library). Thats a pretty edgy edge-case but maybe it helps someone in the future.

I solved it by putting a absolute symbolic link.

Before ln -s ../library after ln -s /the/full/path/to/the/library


My solution is to simply remove a line from the settings.gradle file, which represents a module that doesn't exist:

include ':somesdk'

and also remove the corresponding line from the main project's build.gradle:

compile project(':somesdk')

I had similar issue and found very simple way to add a library to the project.

  1. Create folder "libs" in the root of your project.
  2. Copy JAR file into that folder.
  3. Go back to Android Studio, locate your JAR file and right click it, choose "Add As Library...", it will ask you only to which module you want to add it, well choose "app".

Now in your "app" module you can use classes from that JAR, it will be able to locate and add "import" declarations automatically and compile just okay. The only issue might be is that it adds dependency with absolute path like:

compile files('/home/user/proj/theproj/libs/thelib-1.2.3.jar')

in your "app/build.gradle".

Hope that helps!


For me, one of dependent library does not exist in correct path, but the error message does not point THAT library correctly.

For example, what I missed is :library-3 but the error throws at :library-1.

poor gradle.


I also faced the same issue and it resolved by changing one flag (gradle.ext.set("allowLocalEdits", true)) to false in settings.xml.


Yet another cause - I was trying to include a module in settings.gradle using

include ':MyModule'
project(':MyModule').projectDir = new File(settingsDir, '../../MyModule')

Only problem was, I had just imported the module from Eclipse an forgot to move the directory outside my application project, i.e. the path '../../MyModule' didn't exist.


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to gradle

Gradle - Move a folder from ABC to XYZ A failure occurred while executing com.android.build.gradle.internal.tasks Gradle: Could not determine java version from '11.0.2' Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 Failed to resolve: com.android.support:appcompat-v7:28.0 Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0)

Examples related to android-studio

A failure occurred while executing com.android.build.gradle.internal.tasks "Failed to install the following Android SDK packages as some licences have not been accepted" error Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Flutter plugin not installed error;. When running flutter doctor ADB.exe is obsolete and has serious performance problems Android design support library for API 28 (P) not working Flutter command not found How to find the path of Flutter SDK