Closed currer closed 6 years ago
@currer 上图中日志提示的是找不到ComponentB类进行自动注册。 是因为cc-settings-demo-b.gradle中配置了扫描IActionProcessor的实现类注册到ComponentB中,但gradle中没有依赖demo_component_b,导致找不到类。 日志起到一个提示作用,功能是正常的。
demo_component_b是为了演示以下内容:
用法跟在同一个app内完全一样
)(需要处理的actionName比较多)
的组件中为了避免IComponent实现类过于臃肿而采取的解耦措施,将具体的actionName交由对应的actionProcessor去处理。需要注意的是:IActionProcessor不是CC框架内部的接口,完全由开发者根据自己需求来自定义,若定义了这种接口需要在gradle中增加配置。
,详情可参考 cc-settings-demo-b.gradle@luckybilly 您好,感谢您的回答解惑,可是不依赖demo_component_b,日志除了不打印IActionProcessor相关的信息外,两个独立app,相互调用的时候,ComponentB是能够找到的。即功能是正常的。问题在于,返回值为-10,调试跟踪发现是进入到ComponentB的oncall回调方法的,但是是找不到IActionProcessor注册的子类的,即和日志反馈一样,未注册成功。
@currer demo_component_b作为app运行时,gradle中配置的AutoRegister参数有没有包含IActionProcessor的扫描(cc-settings-demo-b.gradle中有)
单独运行demo_component_b时,gradle console中应该会打印如下日志:
start auto-register transform...
register scan all class cost time: 188 ms
insert register code to file:/Users/billy/Documents/android/CC/demo_component_b/build/intermediates/transforms/auto-register/debug/1.jar
com/billy/cc/demo/component/b/ComponentB
codeInsertToClassName:com/billy/cc/core/component/ComponentManager.class
insert register code to file:/Users/billy/Documents/android/CC/demo_component_b/build/intermediates/transforms/auto-register/debug/13/com/billy/cc/demo/component/b/ComponentB.class
com/billy/cc/demo/component/b/processor/CheckAndLoginProcessor
com/billy/cc/demo/component/b/processor/GetDataProcessor
com/billy/cc/demo/component/b/processor/GetNetworkDataProcessor
com/billy/cc/demo/component/b/processor/LoginProcessor
com/billy/cc/demo/component/b/processor/ShowActivityProcessor
register insert code cost time: 63 ms
register cost time: 251 ms
PS:可以用JD-GUI工具查看一下class文件(文件路径在日志中已经输出了,如:/Users/billy/Documents/android/CC/demo_component_b/build/intermediates/transforms/auto-register/debug/13/com/billy/cc/demo/component/b/ComponentB.class)
@currer 先执行一下clean吧
@luckybilly 您好,clean后,单独运行demo_component_b,打印结果如下所示,和您给的结果不同。并且继承IComponent是能够找到并注册成功的,而自定义的 [ 'scanInterface' : 'com.billy.cc.demo.component.b.processor.IActionProcessor' , 'codeInsertToClassName' : 'com.billy.cc.demo.component.b.ComponentB' , 'codeInsertToMethodName' : 'initProcessors' , 'registerMethodName' : 'add' ] 是找不到,注册不了。和gradle版本有关吗。测试环境:as3.0.1+gradle4.3
补充:依赖demo_component_b后运行demo就可以注册和调用,
@currer 在根目录的build.gradle中将AutoRegister的版本升级到1.1.1试试
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':demo_component_b:transformClassesWithAuto-registerForDebug'.
Unexpected internal error near index 1 \ ^
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 21s
@currer 这是个windows兼容的bug,我这边没有windows电脑,加个qq群帮我调试一下吧。 CC交流群:686844583
AutoRegister插件兼容windows的bug,版本升级到1.1.3已解决
抱歉,大神再次打扰,学习使用您开源CC框架中,遇到一个问题: // compile project(':demo_component_b')后,自定义的ActionProcessor找不到,不能自动注册。 compile project(':demo_component_b')后,就能注册成功了。 请问就是这样,还是我哪里操作不对呢。。 谢谢您百忙中抽出时间的解答。