Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • 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.

like image 668
Tiberiu Mihai Avatar asked Sep 06 '13 10:09

Tiberiu Mihai


People also ask

What is module in Gradle?

A module is an isolated piece of the bigger project. In a multi-module project, these modules have their own jobs but work together to form the whole project. Most Android projects only have one module, the app module. The build. gradle (Module: app) file here is in the app folder.

What are dependencies in Gradle?

Dependencies refer to the things that supports in building your project, such as required JAR file from other projects and external JARs like JDBC JAR or Eh-cache JAR in the class path. Publications means the outcomes of the project, such as test class files, build files and war files.

Where are dependencies stored in Gradle?

The Gradle dependency cache consists of two storage types located under GRADLE_USER_HOME/caches : A file-based store of downloaded artifacts, including binaries like jars as well as raw downloaded meta-data like POM files and Ivy files.


2 Answers

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
like image 76
Karim Varela Avatar answered Oct 04 '22 03:10

Karim Varela


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') } 
like image 42
Vedant Agarwala Avatar answered Oct 04 '22 05:10

Vedant Agarwala