Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问对于多级依赖的项目是否适用? #14

Closed
CCY0122 opened this issue Jun 19, 2019 · 7 comments
Closed

请问对于多级依赖的项目是否适用? #14

CCY0122 opened this issue Jun 19, 2019 · 7 comments

Comments

@CCY0122
Copy link

CCY0122 commented Jun 19, 2019

作者你好。
假设主工程app依赖module1, 然后module1依赖module2。那么我是否只需将主工程app对module1的依赖方式改为文档中说的embed+compileOnly就可以了?还是说module1对module2的依赖方式也要一样的修改掉?
目前我是遇到了#11类似的问题

@kezong
Copy link
Owner

kezong commented Jun 19, 2019

首先,试用于该插件的应该是library,而不是application。
我先假设主module是library,然后主module依赖于module1, module1依赖module2;

如果module1和module2都需要合入主module中产生的aar中,则需要在主module中添加对module1以及module2的embed依赖(哪怕主module只依赖于module1, 但是module1依赖了module2,所以都需要在主module中加embed)。
而module1和module2之间的依赖关系不用修改,按照官方的implementation就行。

所有的embed关系都应该在主module中添加,不应该在子module中添加。

@CCY0122
Copy link
Author

CCY0122 commented Jun 20, 2019

感谢回答。那主module添加对module2的依赖是只需要embed还是embed+compileOnly?

@kezong
Copy link
Owner

kezong commented Jun 21, 2019

感谢回答。那主module添加对module2的依赖是只需要embed还是embed+compileOnly?

加compileOnly只是为了编码时引用到该依赖可以代码提示,并不会影响实际编译结果,如果你实际上不直接依赖该module,可以只加embed。

@zmylls
Copy link

zmylls commented Jun 26, 2019

作者你好,还是library引用module1,module1引用module2,但是module2中引用了eventbus,okhttp等第三方,这需要特殊处理吗?另外我这里确定已经使用embed引用了所有的module,但是还有会有错误找不到符号的。

@kezong
Copy link
Owner

kezong commented Jun 26, 2019

作者你好,还是library引用module1,module1引用module2,但是module2中引用了eventbus,okhttp等第三方,这需要特殊处理吗?另外我这里确定已经使用embed引用了所有的module,但是还有会有错误找不到符号的。

看你是否需要将eventbus和okhttp整体打包,如果需要整体打包,就需要在library中embed eventbus以及okhttp;
你可以查一下找不到的符号属于哪个module,再看看library是否有embed该module。

@zmylls
Copy link

zmylls commented Jun 26, 2019

需要添加的module都已经使用embed,然后我这里改用了1.1.6版本能成功了。但是碰到另一个问题。我有个基础保common,其中包含Gson的引用,gradle使用的是api的方式引入。打出来的aar中有地方引用了gson,这个时候会报错,因为包中没有gson相关内容。不知道这块有没有什么建议。

目前使用的版本情况是:
gradle插件:3.4.1
gradle-wrapper: 5.1.1
fat-aar: 1.1.6
AndroidStudio: 3.4.1

@kezong
Copy link
Owner

kezong commented Jun 26, 2019

需要添加的module都已经使用embed,然后我这里改用了1.1.6版本能成功了。但是碰到另一个问题。我有个基础保common,其中包含Gson的引用,gradle使用的是api的方式引入。打出来的aar中有地方引用了gson,这个时候会报错,因为包中没有gson相关内容。不知道这块有没有什么建议。

要么将gson通过embed一起打包,要么在app中引入aar的同时通过implementation或者api引入该gson库。

@kezong kezong closed this as completed Jul 26, 2019
@kezong kezong reopened this Jul 26, 2019
@kezong kezong closed this as completed Aug 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants