[英]Gradle build module as .aar and put in another module libs folder
I have a two module in project: app and library. 我在项目中有两个模块:应用程序和库。 Is it possible with gradle to build the library module as .aar and put it in the libs folder of the app module ?
gradle是否可以将库模块构建为.aar并将其放置在app模块的libs文件夹中? I want to do it for release purpose so that the library code will not be exposed.
我想这样做是为了发布目的,这样就不会暴露库代码。
Yes it is possible. 对的,这是可能的。 I receive some projects from one of our vendors that are setup this way to prevent the sharing of their library code:
我从一个供应商那里收到了一些项目,这些项目是通过这种方式设置的,以防止共享其库代码:
I think the important points are as follows. 我认为要点如下。
In the app level Gradle file: 在应用程序级别的Gradle文件中:
dependencies {
fileTree(include: ['*.jar'], dir: 'libs')
...
implementation(name: 'applib', ext: 'aar')
}
The file applib.aar is placed in app/src/main/libs
: 文件applib.aar放置在
app/src/main/libs
:
In the lib level Gradle file of applib: 在applib的lib级Gradle文件中:
apply plugin: 'com.android.library'
After building the library applib, the .aar will be placed in: 构建库applib之后,.aar将放置在:
build/output/aar/applib.aar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.