Gradle sync Error: Configuration named 'default' not found

I want to add to my external library GuillotineMenu-Android . I followed the steps given in the main answer to an existing question How do I add a library project to Android Studio? But I ran into the error when I try to build the project after step 6, i.e. when adding a dependency in app/build.gradle

as compile project(":guillotinemenu")

. I tried all stackoverflow links related to this error but didn't work. I created a folder called libs in my application directory and copied the guillotine project folder . Here is my file build.gradle(Module:app)

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 options) :

    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) :

    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 more information. Thanks in advance.

+3


source to share


1 answer


You should have a structure like this:

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

      

Each module has its own build.gradle

file. Also root/settings.gradle

defines all modules within the project. Don't use other .gradle settings 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:

Following your comment below, I think in your case the library folder is the root folder of another project. This means that you have to reference the module within that 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 build.gradle

like library / build.gradle described above.

+1


source







All Articles