Android Studio Gradle Configuration with name 'default' not found
Asked Answered
P

26

181

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!

Punishment answered 19/6, 2013 at 10:5 Comment(4)
do the library projects declared in settings.gradle all have correctly configured build.gradle files in the project roots? also :library and :android-ColorPickerPreference need to be in directories at the same level in your dir stucture as your settings.gradle file?Fryd
This problem occurred with me when I didn't have a build.gradle file in one of my library projects. Creating this file made the error go away.Shiau
In my case one of my gradle configuration file is missing.It is not properly push.Drummond
how to create gradle.build file ..i'm also facing same issue?Scrannel
S
82

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
Summerwood answered 25/10, 2013 at 6:57 Comment(6)
How did you get it to evaluate ':libraries:VolleyLibrary'? What does that line look like in your build.gradle file?Shiau
dependencies{ compile ':libraries:VolleyLibrary'} It should be something like this and nothing more.Summerwood
According to your code sample above, :Libraries should be capitalized.Shiau
For some reason, on Ubuntu, gradlew is not marked as executable. It was trivial to fix: chmod +x gradlew, then ./gradlew tasks --info in my case revealed the problem with a missing git submodule.Vocalise
How do you compile with "gradle tasks --info"?Presber
./gradlew tasks --info this will show the information of all the tasks. I think this would be helpful to find out what is going wrong.Twoseater
S
60

I forgot to pull all submodules. So my

compile project(':something')

could not be resolved.

Solution

git submodule update --init
Snowwhite answered 16/7, 2015 at 11:13 Comment(3)
Please explain on which folder should i run this command - project folder or submodule folderNoontide
this one should be accepted answer. misleading error message in most cases means that you forgot to clone submodulesProtein
In my case I hard forgot to remove the submodule from settings.gradle file. So be careful! :DFrench
H
20
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

Hannis answered 2/4, 2015 at 8:37 Comment(0)
V
19

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
Virescent answered 7/11, 2013 at 9:31 Comment(3)
When I select the library project module settings isn't an option and f4 does nothing.Rubricate
@DanielBaughman please clarify your query, but in case you are still unable to find the module settings, you can do 2 things: 1) Go to File > Import Module and follow the steps, Android Studio will automatically add the build.gradle file and also add the dependencies. 2) Manually add the build.grade file write the script in it and your problem will be resolved.Virescent
Thank you for your help. What I had done is actually put the folder I was importing into the project - imported the module, and then, in my project properties, referenced the source module I had targeted to be imported as the library instead of the new module folder it created. I adjusted that reference and it fixed it.Rubricate
C
12

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

Chemurgy answered 12/9, 2013 at 6:44 Comment(0)
J
10

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.

Jersey answered 2/2, 2016 at 18:34 Comment(1)
This was more or less my issue as well. I had one too many ../ in the path and it wasn't pointing to the correct place. This is especially hard to track down because Android Studio / Gradle will create the directory if it doesn't exist. Instead of throwing a simple error saying "Nope."Charliecharline
G
7

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')
Grau answered 1/4, 2016 at 11:47 Comment(0)
B
6

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.

Barraza answered 16/9, 2013 at 19:46 Comment(0)
B
5

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

Bow answered 26/2, 2014 at 14:30 Comment(2)
to be clear, go to github project sliding-menu github.com/jfeinstein10/SlidingMenu/tree/master/library and check its structure! There is old format android project + build.gradle file!! Thanks, @ABFORCE +1Mailman
This post helped me with importing OpenCV4Android into Android Studio, so I'll vouch for this method.Blaseio
G
5

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.

Gadmann answered 5/3, 2014 at 11:13 Comment(0)
L
4

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

Longsighted answered 24/4, 2017 at 6:51 Comment(0)
P
3

Everything looks fine at first blush, but some poking around on here found an answer that could be helpful: https://mcmap.net/q/137828/-problems-trying-to-create-gradle-build

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.

Philender answered 19/6, 2013 at 15:21 Comment(0)
S
2

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.

Scar answered 31/7, 2013 at 15:46 Comment(0)
L
2

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!

Lefton answered 20/2, 2015 at 15:3 Comment(0)
O
2

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.

Ontina answered 4/5, 2016 at 8:37 Comment(0)
S
1

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.+'
Shiau answered 25/2, 2014 at 18:24 Comment(0)
D
1

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.

Dunite answered 24/12, 2014 at 13:34 Comment(0)
L
1

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')
}
Lapoint answered 20/3, 2015 at 17:28 Comment(0)
O
1

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.

Onto answered 19/5, 2016 at 12:49 Comment(0)
B
1

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
Bettencourt answered 21/6, 2016 at 18:23 Comment(0)
D
0

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'
}
Dominoes answered 20/10, 2015 at 22:11 Comment(0)
M
0

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.

Marchelle answered 29/10, 2015 at 9:48 Comment(0)
B
0

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

Bullnecked answered 27/11, 2015 at 15:5 Comment(0)
T
0

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

Thorlay answered 15/12, 2015 at 15:3 Comment(0)
B
0

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.

Brendin answered 9/12, 2016 at 9:32 Comment(0)
L
-1

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.

Ln answered 4/1, 2016 at 11:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.