I have an Android project in IntelliJ IDEA. It consists of two modules: app and library. App depends on library and library depends on app (Yes, it's not good, but I have what I have and can't change this). IDEA in project settings warn me about circular dependencies, but project builds correctly. Project structure looks like this:
project
|__app
| |__src
| |__build.gradle
|__libarary
| |__src
| |__build.gradle
|__build.gradle
|__settings.gradle
Now I'm trying to migrate to new Android build system based on Gradle and have a trouble here. In my build.gradle
from app
module I add dependency on library
compile project(":library")
Also I tryed to add dependency in library
on app
like
compile project(":app")
But gets error from build system, when gradle trys to assemble library module:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
> Module version project:app:unspecified depends on libraries but is not a library itself
What I can do with this without changing project structure
In software engineering, a circular dependency is a relation between two or more modules which either directly or indirectly depend on each other to function properly. Such modules are also known as mutually recursive.
Or in other words, the cell that the formula is entered in, is within the range that the formula refers to. This causes a circular dependency error. What is this? To fix this error, simply add the tab name to the references in the filter formula.
Avoiding circular dependencies by refactoring Circular dependencies create tight couplings between the classes or modules involved, which means both classes or modules have to be recompiled every time either of them is changed.
Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process, while allowing you to define flexible custom build configurations. Each build configuration can define its own set of code and resources, while reusing the parts common to all versions of your app.
This parameters have changed.
You should now refactor:
In the library project use:
apply plugin: 'com.android.library'
In the app project use:
apply plugin: 'com.android.application'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With