AndroidStudio - Module Dependencies in Gradle
Asked Answered
A

3

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.

Azilian answered 6/9, 2013 at 10:51 Comment(3)
lol don't just give up!Sansen
This happens when I want to learn something. If I can in one way, I try something else. I moved to IntelliJ on which AndroidStudio is based and basically is the same thing. In one way or another. First of all, learn your IDE. This is what I learned. :)Azilian
Great! Glad to hear that :)Sansen
D
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
Dominick answered 4/10, 2013 at 18:34 Comment(5)
Thanks Karim. Kinda late but better later than never right?Azilian
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'Henryson
The desccription is outdated and step 3. above is not possible at allAntiar
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...Screwdriver
I wonder why adding module like this does not update gradle file?Bounteous
U
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')
}
Ultraconservative answered 12/1, 2016 at 10:45 Comment(3)
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!Gardie
this is deprecated nowScrivner
I doubt it is deprecated KathiBander
B
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
Brno answered 2/6, 2021 at 9:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.