luckybilly / CC

业界首个支持渐进式组件化改造的Android组件化开源框架,支持跨进程调用。Componentize your android project gradually.
https://luckybilly.github.io/CC-website/
Apache License 2.0
4.04k stars 636 forks source link

IComponent 注册不成功? #1

Closed currer closed 6 years ago

currer commented 6 years ago

新建module可以创建Component可注册成功并且可以调用成功,但是修改原有的module gradle文件后,却调用始终返回-5,即找不到Component。配置都配置了。不过差异是原有的module里会引用其他的插件例如greendao这样的,是否有影响AutoRegister注册?? image

image

currer commented 6 years ago

补充说明:TestActivity 虽然注册不了Component333 但是可以调用Component111和Component222

luckybilly commented 6 years ago

@currer 请看一下gradle console中打印的日志,是否包含Component333. 日志内容示例:


start auto-register transform...

register scan all class cost time: 253 ms

insert register code to file:/Users/billy/Documents/android/CC/demo/build/intermediates/transforms/auto-register/debug/jars/1/4/fedf7513f848ce76b886caa086034eea0df860da_50dc90e02c76483f2bd78a3f704f2d49.jar
com/billy/cc/demo/component/a/ComponentA
com/billy/cc/demo/lifecycle/LifecycleComponent

codeInsertToClassName:com/billy/cc/core/component/ComponentManager.class

register insert code cost time: 101 ms
register cost time: 354 ms
currer commented 6 years ago

我又重新在Component333同级位置创建了一个Component444,然后运行,除了 image 外仅有红色的: image

luckybilly commented 6 years ago

@currer 是不是没有添加cc库的依赖啊compile "com.billy.android:cc:0.3.1"

日志上显示:找不到ComponentManager类

可参考:https://github.com/luckybilly/CC/blob/master/cc-settings.gradle

currer commented 6 years ago

@luckybilly 你好,我是有配置的: image 此本地的cc-settings.gradle和服务器上的相同,未做修改,所以疑问为何注册不了。

currer commented 6 years ago

另外一个module中基本相同的配置,但不含greendao,结果是这样: image

currer commented 6 years ago

补充说明,未成功中还有一处不同,是配置的 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }

luckybilly commented 6 years ago

@currer 能不能去掉greendao的插件测试一下看看?

currer commented 6 years ago

因为此module是原有的,取消了,报大量错。我试试看先,谢谢。

currer commented 6 years ago

@luckybilly 你好,两种我进行了测试,发现去掉 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } 就可以了。

image

currer commented 6 years ago

确实这样,往test那个之前成功的module中加入上述配置立刻就找不到了: image

luckybilly commented 6 years ago

@currer 好的,谢谢你的反馈,应该是AutoRegister对java8的兼容问题,这两天我找个时间兼容一下

currer commented 6 years ago

@luckybilly 向您学习了很多,很高兴能够帮助测试出问题,希望您越来越好。

luckybilly commented 6 years ago

找到原因了:jack编译模式下不兼容TransformAPI

luckybilly commented 6 years ago

@currer 如果app启用了jack编译模式代替javac+dx,将会导致AutoRegister失效

        jackOptions {
            enabled true
        }

谷歌官方已经废弃了jack :https://android-developers.googleblog.com/2017/03/future-of-java-8-language-feature.html

deprecate the Jack toolchain

所以,抱歉,AutoRegister不打算(也不能)兼容jack了!

其它参考文章: http://trickyandroid.com/the-dark-world-of-jack-and-jill/ https://medium.com/mindorks/the-jack-and-jill-should-you-use-in-your-next-android-application-ce7d0b0309b7

currer commented 6 years ago

嗦嘎,但我并未设置 jackOptions { enabled true } 仅仅新建了一个module并且在它的gradle配置文件中设置了 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } 就找不到了额...

com.android.tools.build:gradle:3.0.1 版本添加 java8,应该默认不打开jack的吧。

luckybilly commented 6 years ago

@currer AutoRegister V1.1.0已修复此问题,兼容java8