简体   繁体   中英

What is the difference between a project dependency and other dependencies

I'm working on another issue with getting my build.gradle to understand a workspace project dependency in my Android project. I've been using Java and Android for a while and I'm still easily confused about all the different ways to add a dependency. One way is to put a .jar file in the libs/ folder. Another way is to have a workspace project dependency. Another way (if working with Android) is to add a project dependency in the Android options menu? I feel like if I truly understood why there are these different dependencies and how they work maybe I wouldn't constantly have issues with managing my dependencies (even with Gradle). Why would one want a project dependency instead of a normal .jar in the libs/ folder? I'm not even sure how a project dependency itself works. By project dependency, I mean something like the Google Play Services project that I have to import into my Eclipse workspace. When importing into Eclipse it doesn't copy the actual directory into the workspace but it's more like a link to the directory. I know this is a big topic, maybe someone can show me a concise place to gain information.

Speaking in general terms, if you add a jar to lib folder, it will (usually) be packed along with the rest of your code. Project dependency adds a compile-time dependency, but (as you already said) it will not be packed into your build. However, that dependency will have to be satisfied at runtime (meaning, for example, Google Play Services will have to exist on the device that runs your code). Aside from that, gradle keeps "its own set of dependencies" to be able to build the application not depending on the IDE you are using. But most IDEs are well integrated with build tools, so they automatically synchronize dependencies between IDE project dependencies, and build tool's dependencies. I hope this makes sense :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM