Gradle sync Error:Configuration with name 'default' not found

10,503

You should have a structure like this:

projectRoot
  app
     build.gradle
  library
     build.gradle
  build.gradle
  settings.gradle

Each module has own build.gradle file. Also the root/settings.gradle defines all modules inside a project. Don't use another settings.gradle inside your module.

In settings.gradle :

include ':app', ':library'

In build.gradle

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.2.3'

            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    allprojects {
        repositories {
            jcenter()
        }
    }

In library/build.gradle

apply plugin: 'com.android.library'

android {
    compileSdkVersion ...
    buildToolsVersion ...

    defaultConfig {
        ....
    }

}

dependencies {
   //....
}

In app/build.gradle use your file but change:

dependencies {
    //...
    // GuillotineMenu
    compile project(":library")
}

UPDATE:

After your comment below, I think that in your case the library folder is the root folder of another project. It means that you should refer to the module inside this project.

    projectRoot
      app
         build.gradle
      libs
         guillotinemenu
           build.gradle //top level file of guillotinemenu project
    -->>   module       
              build.gradle  //build.gradle of the module

So change the settings.gradle of your projectRoot.

 include ':app', ':guillotinemenu'
 project(':guillotinemenu').projectDir = new File('libs/guillotinemenu/module')

The module (libs/guillotinemenu/module) should have a build.gradle as the library/build.gradle described above.

Share:
10,503
gautamprajapati
Author by

gautamprajapati

SOreadytohelp

Updated on June 05, 2022

Comments

  • gautamprajapati
    gautamprajapati almost 2 years

    I want to add an external library GuillotineMenu-Android in my application. I followed the steps given in the most upvoted answer to an existing question How do I add a library project to the Android Studio? But I am facing error when I try to build project after step 6 i.e. when added dependency in app/build.gradle as compile project(":guillotinemenu"). I tried all the stackoverflow links related to this error but its not working out. I have made a folder named libs in my app directory and copied the project folder guillotine menu there. Here is my build.gradle(Module:app) file

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 22
        buildToolsVersion "22.0.1"
        defaultConfig {
            applicationId "com.sunshine.bbreaker.appet_i"
            minSdkVersion 14
            targetSdkVersion 22
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        productFlavors {
        }
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:recyclerview-v7:+'
        compile 'com.github.navasmdc:MaterialDesign:1.+@aar'
        compile 'com.android.support:appcompat-v7:22.0.+'
    
        // GuillotineMenu
        compile project(":guillotinemenu")
    }
    

    settings.gradle(Project Settings) file:

        include ':app', ':guillotinemenu'
    project(':guillotinemenu').projectDir = new File('libs/guillotinemenu')
    

    build.gradle(Project:guillotinemenu) file:

    buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
    
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }} allprojects {
    repositories {
        jcenter()
    }}
    

    settings.gradle(Project:guillotinemenu) file:

    include ':app', ':library'
    

    build.gradle(guillotinemenu) file:

        apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 22
        buildToolsVersion "21.1.2"
    
        defaultConfig {
            applicationId "com.yalantis.guillotine.sample"
            minSdkVersion 15
            targetSdkVersion 22
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        compile project(':library')
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:22.1.1'
        compile 'com.jakewharton:butterknife:6.1.0'
    }
    

    Let me know if you need any more information. Thanks in advance.

  • gautamprajapati
    gautamprajapati almost 9 years
    the library guillotinemenu is already having its build.gradle file and settings.gradle file. It is using another library inside it which have just a build.gradle file. So, do you want me to change or delete settings.gradle of guillotinemenu project?
  • Gabriele Mariotti
    Gabriele Mariotti almost 9 years
    @brainbreaker It wasn't clear in the original question, sorry. I've updated the answer. If the guillotinemenu is another project you have to point the module inside this project