问题
I am using Gradle for Android with Eclipse (NOT Android Studio and please do not suggest to change the IDE).
My project.properties
file got this line:
android.library.reference.1=..\\google-play-services_lib
I tried adding this line to build.gradle:
compile project('..\\google-play-services_lib')
When building the project I get this error:
Project with path '..\google-play-services_lib' could not be found in root project 'myProject'.
What am I doing wrong?
How do I define in the build.gradle the jars I've added to the build path?
回答1:
If you want to compile sources of your library :
1) Put your project library in your root project
Tree is like the following :
RootProject
+- build.gradle
+- settings.gradle
+- Lib1/
+- build.gradle
+- ...
+- Project/
+- build.gradle
+- ...
2) Edit your settings.gradle
include ':Lib1'
include ':Project'
3) Add dependency in your Project's build.gradle file
dependencies {
[...]
compile project(':Lib1')
}
If you want to add jars :
1) Create a libs folder in your Project's dir
2) Add this dir as reprositories in your gradle file
repositories {
flatDir {
dirs 'libs'
}
}
3) Put your jar in this dir and add dependencies in your Project's build.gradle
dependencies {
compile(name:'mylib',ext:'jar')
}
来源:https://stackoverflow.com/questions/40451312/set-project-dependencies-with-gradle