简体   繁体   English

从多个模块编译一个.aar库文件

[英]Compiling one .aar library file from multiple modules

Hello everyone I have library project that consists from multiple modules : 大家好,我有一个由多个模块组成的图书馆项目:

  • module 1 模块1
  • module 2 模块2
  • module 3 模块3
  • module 4 模块4

I want to export all four modules as one .aar library file so I'm thinking about generating .aar files for each module and including it to other .aar file I'm not sure if this is going to work or is this good practice so I want your opinions on that ? 我想将所有四个模块导出为一个.aar库文件,因此我正在考虑为每个模块生成.aar文件,并将其包含到其他.aar文件中,我不确定这是否可行或这种好习惯所以我希望你对此发表意见? And what is the best way to compile one .aar file from multiple modules ? 从多个模块编译一个.aar文件的最佳方法是什么?

stack=java.lang.NoClassDefFoundError: Failed resolution of: Ldagger/internal/Preconditions .... Caused by: java.lang.ClassNotFoundException: Didn't find class "dagger.internal.Preconditions" on path: DexPathList[[... stack = java.lang.NoClassDefFoundError:无法解决以下问题:Ldagger / internal / Preconditions...。由以下原因引起:java.lang.ClassNotFoundException:在路径:DexPathList [[.. 。

It's seems dependencies don't get included into .aar file. 似乎相关性没有包含在.aar文件中。

the "standard" way of doing it is to just direct use the modules in the compilation process that will generate the 1 aar. “标准”方法是在编译过程中直接使用将生成1 aar的模块。

So let's say module1 is the main part of the library, you'll have the following on it's build.gradle 因此,假设module1是库的主要部分,您将在build.gradle上看到以下build.gradle

apply plugin: 'com.android.library' // it's a library, generates aar

dependencies {
    // the other modules are dependencies on this one
    compile project(':module2')
    compile project(':module3')
    compile project(':module4')
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM