14

Android Module引用另一个Module,却无法使用里面的依赖库

 3 years ago
source link: https://renyugang.blog.csdn.net/article/details/86262031
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Android Module引用另一个Module,却无法使用里面的依赖库

original.png
identityVip.png VIP文章 胖虎 2019-01-10 23:00:35 articleReadEyes.png 16329

如果模块化开发中遇到

多模块的AndroidManifest.xml没有合并
or
多模块的资源文件没有合并
or
模块A include了模块B,而无法使用模块B内依赖的其他aar包中的类的时候
or
提示Support包版本不一致
这篇文章可能就是你要的解决方案~

举个栗子:

比如我们现在有一个App模块设计为:
主工程: app
模块: ui , framework

引入模块的方式:在settings.gradle中,指定正确的模块路径

include ':app', ':framework', ':ui'
project(':framework').projectDir = new File('../framework')
project(':ui').projectDir = new File('../ui')

如果现在framework引入了一些依赖库,假设如下:


	// Retrofit 网络框架依赖
    implementation "com.squareup.retrofit2:retrofit:2.5.0"

    // Gson 依赖
    implementation 'com.google.code.gson:gson:2.8.5'

    // ARouter解耦框架
    implementation 'com.alibaba:arouter-api:1.4.1'
    annotationProcessor 'com.alibaba:arouter-compiler:1.2.2'

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK