编译与编译树与编译文件之间的区别? [英] difference between compile vs compile tree vs compile Files?
问题描述
我试图将我的项目集成到 android studio 中.但是在添加依赖项时我有点困惑.我不知道哪个效果好.我试过编译 fileTree 和编译文件.它对我不起作用.我找到了一些方法.谁能告诉我哪种方法适合添加库(jar文件只类似于admob).
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')
推荐答案
谁能告诉我哪一种适合添加库(jar文件只有admob).
can any one tell me which one is appropriate for adding library (jar file only like admob).
如果库可作为 Maven 或 Ivy 存储库(如 Maven Central)中的工件使用,请将存储库添加到您的 repositories
块(例如,mavenCentral()
)然后使用 compile 'com.android.support:appcompat-v7:+'
,用标识您想要的工件的字符串替换带引号的字符串.
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.
如果库不能用作工件,请将 JAR 放在适当的目录中(例如,项目级别的 libs/
)并使用 compile fileTree(dir: 'libs', 包括:'*.jar')
.
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")
用于您可能没有的子项目.
compile project(":libraries:libraryname")
is for sub-projects, which you probably do not have.
compile files('libs/libraryname.jar')
有效,但 compile fileTree(dir: 'libs', include: '*.jar')
更有效灵活,因为您不必为每个 JAR 更改 build.gradle
文件.
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.
这篇关于编译与编译树与编译文件之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!