title: build.gradle and project libs
body: <p>I have a project in android studio that uses a project library. 
  My problem is the configuartion of the gradle files. </p>
  
  <p>I really tried a  lot of solution that were posted here (<a href="https://stackoverflow.com/questions/16971375/android-gradle-build-with-sub-projects">define modul in project lib in settings as modul</a>, <a href="https://stackoverflow.com/questions/16588064/how-do-i-add-a-library-project-to-the-android-studio">sherlock example</a>, <a href="https://stackoverflow.com/questions/16905214/problems-trying-to-create-gradle-build/16905808#16905808">setting right sourcesets</a> ...), but I always get the same error (as soon as I add the lib debendency to my apps build.gradle file):</p>
  
  <pre><code>A problem occurred configuring project ':MyApp'.
  &gt; Failed to notify project evaluation listener.
     &gt; Configuration with name 'default' not found.
  </code></pre>
  
  <p>I already did a clean and build from command line, but this has no effect.
  Is it possible that this is just a bug in the early version of Android Studio (<a href="https://stackoverflow.com/questions/16654904/cant-build-application-when-using-libraries">like the comment in this post</a>)? Or do I miss something?</p>
  
  <p>My current Android Studio Version: 0.1.6 and my OS: Windows 7, 64bit</p>
  
  <p>Please help me, I'm new to gradle and I never used maven or ant before.</p>
  
  <p><strong>EDIT 1:</strong></p>
  
  <pre><code>gardelw compileDebug --stacktrace
  
  * Exception is:
  
  org.gradle.api.ProjectConfigurationException: A problem occurred configuring pro
  ject ':MyApp'.
          at org.gradle.configuration.LifecycleProjectEvaluator.addConfigurationFa
  ilure(LifecycleProjectEvaluator.java:79)
          at org.gradle.configuration.LifecycleProjectEvaluator.notifyAfterEvaluat
  e(LifecycleProjectEvaluator.java:74)
          at org.gradle.configuration.LifecycleProjectEvaluator.evaluate(Lifecycle
  ProjectEvaluator.java:61)
          at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProj
  ect.java:465)
          at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProj
  ect.java:76)
          at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuil
  dConfigurer.java:31)
          at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(Default
  GradleLauncher.java:142)
          at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradle
  Launcher.java:113)
          at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLaun
  cher.java:81)
          at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildCon
  troller.run(InProcessBuildActionExecuter.java:64)
          at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.jav
  a:33)
          at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.jav
  a:24)
          at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
  ssBuildActionExecuter.java:35)
          at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
  ssBuildActionExecuter.java:26)
          at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
          at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions
  .java:171)
          at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.
  execute(CommandLineActionFactory.java:201)
          at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.
  execute(CommandLineActionFactory.java:174)
          at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
  CommandLineActionFactory.java:170)
          at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
  CommandLineActionFactory.java:139)
          at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep
  ortingAction.java:33)
          at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep
  ortingAction.java:22)
          at org.gradle.launcher.Main.doAction(Main.java:48)
          at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
          at org.gradle.launcher.Main.main(Main.java:39)
          at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBoots
  trap.java:50)
          at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.j
  ava:32)
          at org.gradle.launcher.GradleMain.main(GradleMain.java:26)
          at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.ja
  va:33)
          at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
          at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
  Caused by: org.gradle.listener.ListenerNotificationException: Failed to notify p
  roject evaluation listener.
          at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java
  :90)
          at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java
  :30)
          at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocat
  ionHandler.invoke(ProxyDispatchAdapter.java:93)
          at com.sun.proxy.$Proxy8.afterEvaluate(Unknown Source)
          at org.gradle.configuration.LifecycleProjectEvaluator.notifyAfterEvaluat
  e(LifecycleProjectEvaluator.java:67)
          ... 29 more
  Caused by: org.gradle.api.artifacts.UnknownConfigurationException: Configuration
   with name 'default' not found.
          at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration
  Container.createNotFoundException(DefaultConfigurationContainer.java:94)
          at org.gradle.api.internal.DefaultNamedDomainObjectCollection.getByName(
  DefaultNamedDomainObjectCollection.java:184)
          at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration
  Container.getByName(DefaultConfigurationContainer.java:84)
          at org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependen
  cy.getProjectConfiguration(DefaultProjectDependency.java:72)
          at org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependen
  cy_Decorated.getProjectConfiguration(Unknown Source)
          at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.getPropert
  y(BeanDynamicObject.java:146)
          at org.gradle.api.internal.BeanDynamicObject.getProperty(BeanDynamicObje
  ct.java:102)
          at org.gradle.api.internal.CompositeDynamicObject.getProperty(CompositeD
  ynamicObject.java:78)
          at org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependen
  cy_Decorated.getProperty(Unknown Source)
          at com.android.build.gradle.BasePlugin$_ensureConfigured_closure92.doCal
  l(BasePlugin.groovy:1252)
          at com.android.build.gradle.BasePlugin.ensureConfigured(BasePlugin.groov
  y:1250)
          at com.android.build.gradle.BasePlugin$ensureConfigured.callCurrent(Unkn
  own Source)
          at com.android.build.gradle.BasePlugin.resolveDependencyForConfig(BasePl
  ugin.groovy:1214)
          at com.android.build.gradle.BasePlugin$resolveDependencyForConfig.callCu
  rrent(Unknown Source)
          at com.android.build.gradle.BasePlugin.resolveDependencies(BasePlugin.gr
  oovy:1164)
          at com.android.build.gradle.BasePlugin$resolveDependencies.callCurrent(U
  nknown Source)
          at com.android.build.gradle.AppPlugin.doCreateAndroidTasks(AppPlugin.gro
  ovy:196)
          at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.gro
  ovy:242)
          at com.android.build.gradle.BasePlugin$_apply_closure1.doCall(BasePlugin
  .groovy:190)
          at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(Cl
  osureBackedMethodInvocationDispatch.java:40)
          at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(Cl
  osureBackedMethodInvocationDispatch.java:25)
          at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java
  :81)
          ... 33 more
  
  
  BUILD FAILED
  
  Total time: 2.947 secs
  </code></pre>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>project structure:</p>
  
  <pre><code>MyProject
  - MyApp
    -- build.gradle
    -- libraries
       --- projectLib
           --- build.gradle
  - build.gradle
  - settings
  </code></pre>
  
  <p>settings.gradle</p>
  
  <pre><code>include ':MyApp'
  include ':libraries:projectLib'
  // also tried to define projectLib as modul:
  // project(':projectLib').projectDir = new File('MyApp/libraries/projectLib')
  </code></pre>
  
  <p>build.gradle of MyApp:</p>
  
  <pre><code>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(':libraries:projectLib') // adding this line 
                                               // --&gt; build failed
  }
  
  android {
      compileSdkVersion 17
      buildToolsVersion "17.0.0"
  
      defaultConfig {
          minSdkVersion 7
          targetSdkVersion 16
      }
  
      sourceSets{
          main{
              manifest.srcFile 'src/main/AndroidManifest.xml'
              java.srcDirs = ['src']
              resources.srcDirs = ['src']
              res.srcDirs = ['src/main/res']
              aidl.srcDirs = ['res']
              assets.srcDirs = ['assets']
              renderscript.srcDirs = ['src']
          }
      }
  }
  </code></pre>
  
  <p>build.gradle of projectLib:</p>
  
  <pre><code>buildscript {
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:0.4'
      }
  }
  apply plugin: 'android-library'
  
  dependencies {
      compile fileTree(dir: 'libs', include: '*.jar')
  }
  
  android {
      compileSdkVersion 17
      buildToolsVersion "17.0.0"
  
      defaultConfig {
          minSdkVersion 7
          targetSdkVersion 16
      }
  
      sourceSets{
          main{
              manifest.srcFile 'AndroidManifest.xml'
              java.srcDirs = ['src']
              resources.srcDirs = ['src']
              res.srcDirs = ['res']
              aidl.srcDirs = ['res']
              assets.srcDirs = ['assets']
              renderscript.srcDirs = ['src']
          }
      }
  }
  </code></pre>
  
  <p><strong>EDIT 3:</strong></p>
  
  <p><strong>settings.gradle</strong></p>
  
  <pre><code>include ':MyApp'
  include ':MyApp:libraries:projectLib'
  </code></pre>
  
  <p><strong>build.gradle of MyApp:</strong></p>
  
  <pre><code>buildscript {
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:0.4.2'
      }
  }
  apply plugin: 'android'
  dependencies {
      compile 'com.android.support:support-v4:13.0.0'
      compile project(':MyApp:libraries:projectLib')
  }
  </code></pre>
  
  <p><strong>build.gradle of projectLib:</strong></p>
  
  <pre><code>buildscript {
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:0.4.2'
      }
  }
  apply plugin: 'android-library'
  
  dependencies {
      compile 'com.android.support:support-v4:13.0.0'
  }
  </code></pre>