编译与编译树之间的区别vs编译文件? [英] difference between compile vs compile tree vs compile Files?

查看:179
本文介绍了编译与编译树之间的区别vs编译文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的项目整合到Android工作室。但是当添加依赖关系时我很困惑。我不知道哪一个是正常的工作。我已经尝试编译fileTree和编译文件。它不为我工作。我找到了一些方法。任何人都可以告诉我哪一个适合添加库(jar文件只能像admob)。

  compile fileTree(dir:'libs',include:'* .jar')
编译'com.android.support:appcompat-v7:+'
编译项目(:libraries:libraryname)
编译文件('libs / libraryname.jar')


解决方案

blockquote>

可以任何人告诉我哪一个适合添加库(jar文件只能像admob)。


如果图书馆作为Maven或Ivy存储库中的工件可用,如Maven Central,请将存储库添加到您的存储库块中(例如, mavenCentral()),然后使用 compile'c​​om.android.support:appcompat-v7:+',将引用的字符串替换为识别您想要的工件。



如果库不可用一个工件,将JAR放在相应的目录(例如项目级别的 libs / )中,并使用 compile fileTree(dir:'libs'包括:'* .jar')



编译项目(:libraries:libraryname)是用于您可能没有的子项目。



编译文件('libs / libraryname.jar')工作,但编译fileTree(dir:'libs',include:'* .jar')更灵活,因为您不必更改您的每个JAR的 build.gradle 文件。


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')

解决方案

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.

这篇关于编译与编译树之间的区别vs编译文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆