[英]Adding jar file in libs vs. adding dependencies in gradle
We are using projectlombok
in our android app. 我们在我们的Android应用程序中使用
projectlombok
。 Our approach to use this library is - We have added lombok.jar
to the android studio - inside libs
folder and using compile files('libs/lombok.jar')
我们使用此库的方法是-我们在android studio中添加了
lombok.jar
在libs
文件夹中并使用了compile files('libs/lombok.jar')
However, on the project home page of projectlombok the approach explained to add it is like below, 但是,在projectlombok的项目主页上 ,说明的添加方法如下所示,
dependencies {
compileOnly 'org.projectlombok:lombok:1.16.18'
}
Is there any performance or app-size impact of one approach over the other? 一种方法对其他方法的性能或应用程序规模有影响吗?
One of the biggest differences is the amount of work required to upgrade to a new version of the library. 最大的区别之一是升级到该库的新版本所需的工作量。 If you use Gradle, then all it takes is a small edit to your build.gradle file.
如果您使用Gradle,则只需对build.gradle文件进行少量编辑即可。 The other option requires downloading the JAR file manually and copying it to the libs directory.
另一个选项需要手动下载JAR文件并将其复制到libs目录。
For JAR-only libraries, this difference is pretty small. 对于仅JAR的库,这种差别很小。 However, for libraries which also include Android resources, a JAR file is insufficient.
但是,对于还包含Android资源的库,JAR文件不足。 You have to build a AAR file instead and bring it into your build process.
您必须改为构建AAR文件,并将其带入构建过程。 Gradle manages all of this for you.
Gradle会为您管理所有这些。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.