Android 多模块构建

论坛 期权论坛 脚本     
匿名技术用户   2021-1-6 22:49   580   0

一、多模块构建
比如下图是我们现在工程的结构

 
project
├─── setting.gradle
├─── build.gradle
├─── app
│ └─── build.gradle
└─── testlibrary
  └─── build.gradle



要想进行多模块构建,必须要告诉gradle项目的结构以及子文件夹包含模块,这就需要编写settings.gradle。此外,每个模块可以提供独立的build.gradle。

如上图,若想构建上图多模块,在settings.gradle文件中应该是这样的

include ':app'
include ':testlibrary'

此外,为了在app模块中添加library作为依赖,需要在app的build.gradle中添加

 
dependencies {
    implementation project(':testlibrary')  // studuo 3.0之前用compile
}



二、启动library中的Activity
1、需要在app module的manifest里也注册该Activity
2、testlibrary和app这两个module的sdk版本要设置为一直否则可能会报错

Error:(3) Error retrieving parent for item: No resource found that matches the given name 'Android:TextAppearance.Material.Widget.Button.Borderless.Colored'.

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP