difference between compile vs compile tree vs compile Files?

荒凉一梦 提交于 2019-12-12 07:59:20

问题


I was trying to integrate my project in android studio. but i am little confused when adding dependencies. I don't know which one is works good.I have tried Compile fileTree and compile files.Its not working for me . I found some methods.can any one tell me which one is appropriate for adding library (jar file only like admob).

            compile fileTree(dir: 'libs', include: '*.jar')
         compile 'com.android.support:appcompat-v7:+'
       compile project(":libraries:libraryname")
         compile files('libs/libraryname.jar')

回答1:


can any one tell me which one is appropriate for adding library (jar file only like admob).

If the library is available as an artifact in a Maven or Ivy repository, like Maven Central, add the repository to your repositories block (e.g., mavenCentral()) and then use compile 'com.android.support:appcompat-v7:+', replacing the quoted string with the one that identifies the artifact that you want.

If the library is not available as an artifact, put the JAR in the appropriate directory (e.g., libs/ at the project level) and use compile fileTree(dir: 'libs', include: '*.jar').

compile project(":libraries:libraryname") is for sub-projects, which you probably do not have.

compile files('libs/libraryname.jar') works, but compile fileTree(dir: 'libs', include: '*.jar') is more flexible, as you do not have to change your build.gradle file for every JAR.



来源:https://stackoverflow.com/questions/20333193/difference-between-compile-vs-compile-tree-vs-compile-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!