Tiberiu Mihai
Tiberiu Mihai

Reputation: 721

AndroidStudio - Module Dependencies in Gradle

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:

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.

Upvotes: 45

Views: 76699

Answers (3)

yoAlex5
yoAlex5

Reputation: 34311

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

Upvotes: 3

Vedant Agarwala
Vedant Agarwala

Reputation: 18819

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')
}

Upvotes: 71

Karim Varela
Karim Varela

Reputation: 7652

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

Upvotes: 83

Related Questions