JasSy JasSy - 1 month ago 84
Android Question

Circular reference between projects when adding at gradle

I am adding a Easypost library to my Android peoject and from my understanding I need to reference it at both settings.gradle and build.gradle. But when I do that, I get the error:

Error:Circular reference between projects:
:Libs:easypost-java-master -> :Libs:easypost-java-master

If I remove the reference at either one of them, I am able to sync without errors but unable to import com.easypost.EasyPost. So I am guessing I do need to reference at both places but how do I avoid the circular reference error?


include ':app'
include ':Libs:easypost-java-master'


dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile project(':Libs:easypost-java-master')

My project structure

Project Structure


The build.gradle file you marked contains a reference to itself as dependency. This is the shortest possible circular reference. If you remove

compile project(':Libs:easypost-java-master')

you might be fine. I am saying might because I gave up on IntelliJ Idea. Instead of making things easier with regard to Gradle, it just introduced an additional, redundant layer of complexity that I had deal with instead. IntelliJ Idea just did not work out for me.

Best advice I can give is to setup your project manually first in order to understand how gradle handles projects. It is a steep learning curve but in my case it saved a lot more time and headaches in the long run.