45

I have a little problem compiling an android application using module dependencies in Android Studio.

So, I want my application to use the library 'slidingmenu' (link here).

Here is my application tree:

  • Application
  • slidingmenu (source files)
  • slidingmenu-maps-support (source files)

Here is a link to see what I mean.

This is the error I'm getting.

Gradle: A problem occurred configuring project ':Application'.

Failed to notify project evaluation listener.

Configuration with name 'default' not found.

How do I specify a module dependency and where do I put the modules (inside Application or inside ApplicationProject?

Thanks!

EDIT 1: Never mind! I got back to eclipse! Android Studio is just not ready for a true project development.

Tiberiu Mihai
  • 711
  • 1
  • 7
  • 12

3 Answers3

83

You should put your library modules inside the Application Project. In order to specify a module dependency, simply:

  1. Right click on Application->Open Module Settings
  2. Click on the '+' icon
  3. Select the root directory for your library module you'd like to add.
  4. Follow the prompts

Then, this module will show up in your project. Then, you need to add it to Application as a library dependency. Once again, in your Module Settings:

  1. Select your Application module
  2. Select the Dependencies tab on the right
  3. Click the '+' icon on the bottom
  4. Select Module Dependency
  5. Select your desired library module
Karim Varela
  • 7,562
  • 10
  • 53
  • 78
  • Thanks Karim. Kinda late but better later than never right? – Tiberiu Mihai Sep 04 '15 at 10:20
  • Hi @KarimVarela I am getting this error after including the module as dependency. `Error:Execution failed for task ':library:processReleaseGoogleServices'. > No matching client found for package name 'com.firebase.ui'` – Shajeel Afzal Jan 28 '16 at 21:58
  • 1
    The desccription is outdated and step 3. above is not possible at all – Trinimon May 11 '16 at 09:33
  • You may have to expand the window to find the `+` icon. It was at the bottom for me, and hidden until I expanded the window. AndroidStudio loves to present windows that are too small and aren't obvious that they need to be expanded... – Sakiboy Aug 01 '16 at 17:02
  • I wonder why adding module like this does not update gradle file? – fikr4n Feb 13 '17 at 00:37
71

For people using the gradle way (explicitly rather than being generated by the IDE):

Add this to your app's build.gradle:

dependencies {
    ....
    // other dependencies...
    implementation project(':module-name')
}
Idee
  • 1,887
  • 21
  • 31
Vedant Agarwala
  • 18,146
  • 4
  • 66
  • 89
  • I couldn't for the life of me add a dependency through the project dependencies. I could click the +, add module dependency and then when I came back to the module settings window it wouldn't be there. Doing this in my gradle file under dependencies worked! – Flyview Jan 15 '16 at 19:36
  • 1
    this is deprecated now – Kathi Jun 07 '18 at 06:13
  • 6
    I doubt it is deprecated Kathi – Idee Jul 11 '18 at 12:20
2

Add module as dependency

  1. Add module into settings.gradle
include ':MyModule'

//Additionally you can specify  directory here
project(':MyModule').projectDir = new File('SomePath/HelloWorld')
  1. Add dependency into module
dependencies {
    implementation project(':MyModule')
}
  1. Sync Project
yoAlex5
  • 29,217
  • 8
  • 193
  • 205