Comments (8)
谢谢~~
1、basiclib的确是放基础工具类的地方。但是设计资源的BaseActivity等类,建议放到basicres这个module中
2、library的module生成的R不是final的,所以不能用butterknife,这与组件化框架无关,android本身就没法这么用。建议改成dataBinding,感觉更方便
from ddcomponentforandroid.
回复的真快!我是不是可以这么理解: basiclib中是与业务无关的基础类, basicres中是与业务有关的公共资源?
第二个问题,咱们可能没说道一起,我的意思是说: butterknife现在本身是支持在library中使用的
from ddcomponentforandroid.
1、是这样的,basicres主要放一些theme等资源,以及BaseActivity等。
2、那我理解错了,如果butterknife本身在library中可以使用,那么框架也是支持的。框架做的事情就是在编译的时间增加一个任务分析,其本质上还是使用的compile project
from ddcomponentforandroid.
第二个应该需要框架插件适配支持才行,因为要在R文件与R2文件直接切换;
还有一个问题,我有些基础库需要初始化才能用,正常实在主app的baseApplication中初始化的,组件化后,我将这些库下沉到basiclib;然后我是要在每个组件用到的时候都初始化一下?
from ddcomponentforandroid.
以往butterknife不能在library-Module中用的,好像近期的版本进行了支持,可能问题会出现在runalone情况下,因为library-Module中使用R2类,APP-Module中使用R类,但都是写在注解中的,runalone时library-Module的角色变成了APP-Module。可以尝试一下,如果确实有问题的,我看看能不能写一套扩展对Butterknife进行更好的支持。 ps:我还是喜欢使用findviewbyid,尽管使用了遍历。
from ddcomponentforandroid.
@weinierfei 这个问题我后面研究一下,你可以暂时改为dataBinding。
初始化需要区分是集成调试还是单独调试,如果是集成,放在app的Application里面就可以了,如果是单独云运行,则需要在组件的runalone文件夹中创建组件自己的Application,并在这里面进行初始化。
from ddcomponentforandroid.
抽空尝试了一下,使用最新的butterknife(8.8.1)是可行的。对于app module,作为main Module,使用R或者R2类都不影响,对于其他的library 类型的Component,例如shareComponent,注意:layout资源依旧使用R类,id类、String类资源需要使用R2类(array、integer、anim、drawable等未测试)。
layout资源如使用R2类则会抛出NotFound。
其他类型(如id)如使用R类则无法编译,需使用R2。
当shareComponent以runalone形式独立运行时,它本身将作为main module,使用R2也不会有问题。
测试代码我提交到了:feature/butterknife 分支,其中包含了Router的一些代码,可以忽略掉这部分。sample代码是将butterknife的集成测试代码直接移植过来的。
如果发现有新问题的话,可以提出来一起研究下。
关于第二个问题,有这样一种情况:shareComponent集成了某sdk,需要初始化,但是在appModule中并没有集成该sdk,这时候可以将初始化的代码安排在ShareApplike#onCreate()中. 获取Application对象 以及 使用SubApplication中封装的业务 可以参考 issue 30 和 issue 33
而该Component的独立运行可以按照mqzhangw所说,在相应的Application类中进行初始化。
from ddcomponentforandroid.
感谢耐心回复,我尝试一下,谢谢二位
from ddcomponentforandroid.
Related Issues (20)
- 项目报错Unable to find a matching configuration of project HOT 11
- android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? HOT 3
- 在实际公司组件化git部署用的哪种方式
- 打包后找不到子组件的类,怎么解决? HOT 1
- 建议
- basicres添加资源后编译失败 HOT 1
- 同时集成Bubly的Tinker1.9.6热修复时,打补丁包失败 HOT 2
- UI 跳转 List 数据的传递怎么使用? HOT 4
- 关于数据传递的问题 HOT 1
- 修改组件文件后,运行app,报错Failed to delete 组件名字\build\intermediates\intermediate-jars\debug\classes.jar HOT 5
- 没明白 AppShareBean不想将一些类下沉如何处理 是如何处理的 HOT 1
- 低版本无法运行的问题 HOT 1
- 低版本无法运行的问题
- 关于组件化dagger android使用相关问题 HOT 2
- gradle 5.1.1 BUG HOT 1
- 模块引入R文件报红
- 组件化,activity之间的共享动画如何处理呀? HOT 1
- 组件化库维护问题
- 依赖包版本compile 'com.android.support:appcompat-v7:26.+'
- 框架不支持App Bundle
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ddcomponentforandroid.