[英]Create one aar from multi module library in android
I have the following modules in my aaplication我的应用程序中有以下模块
Module模块
-app
-library_1
-library_2
the module library_1
'has dependecy of library_2
build gradle library_1模块
library_1
'具有 library_2 的依赖关系 build gradle library_2
dependencies {
api project(":library_2")
}
When I build the project I get the aar which I put in my app module当我构建项目时,我得到了我放入我的应用程序模块的 aar
dependencies {
implementation files('libs/library_1-debug.aar')
}
Now when I run my app I get the exception java.lang.NoClassDefFoundError: Failed resolution of: Lcom/dinklo/library_2/LibraryB
现在,当我运行我的应用程序时,出现异常
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/dinklo/library_2/LibraryB
The class LibraryB
is defined in library_2
and being called from library_1
class
LibraryB
在library_2
中定义并从library_1
调用
I am looking for a solution where I can get a single aar file for all the modules I have.我正在寻找一种解决方案,我可以在其中为我拥有的所有模块获取一个 aar 文件。
I ended up using third party library Fat-aar我最终使用了第三方库Fat-aar
In root build gradle在根构建 gradle
classpath 'com.github.kezong:fat-aar:1.3.8'
In your library module在您的图书馆模块中
apply plugin: 'com.kezong.fat-aar'
dependencies{
embed project(path: ':lib-2', configuration: 'default')}
I have added a sample project on github will be usefol for others我在 github 上添加了一个示例项目,将对其他人有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.