在build.gradle文件中:
compile (project(':com.test.model'))
在settings.gradle文件中写:
include ':com.test.model'
project(':com.test.model').projectDir = new File(settingsDir, '../com.test.model')
如果还有其他项目依赖,只要重复添加上面的依赖就行。
因为我的项目会出现重复依赖关系,比如c依赖a、b,b又依赖a,我添加了上面的依赖之后报错了,后来发现是我写的语法有错误,在build.gradle文件中的写法必须是加上括号的,就是上面红背景的那个地方,这样就正确了。
最开始的时候是这样写的,后来发现还是有问题,在另外一个地方发现了答案。http://blog.csdn.net/w8452960/article/details/53415415
我的就是多个工程平行,有互相依赖关系.
比如
A
B
C
三个工程
B依赖A,需要在settings.gradle中写上:
includeFlat 'A'
在build.gradle写上:
compile project(':A')
如果C要依赖B的话,需要把A也写上
settings.gradle中
includeFlat 'A','B'
build.gradle中
compile project(':A')
compile project(':B')
在编译时还有问题的话,可以试试:
gradle cleanEclipseClasspath eclipseClasspath
-----------------------
【https://stackoverflow.com/questions/30508993/invalid-classpath-publish-export-dependency-ouat-contract-project-entries-not】
-
Run command: gradle cleanEclipse eclipse
- as a result of this command Eclipse forgets that the project was supposed to have a gradle nature.
-
Add gradle nature back to the project by doing Configure -> Convert to Gradle Project.
- as a result of this command the error reappears.
- if incompatible plugin java version error appears then just delete .settings directory and refresh.
-
Run command: gradle cleanEclipseClasspath eclipseClasspath
- this final step should get it fixed until the next time.