Closed currer closed 6 years ago
补充说明:TestActivity 虽然注册不了Component333 但是可以调用Component111和Component222
@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
我又重新在Component333同级位置创建了一个Component444,然后运行,除了 外仅有红色的:
@currer 是不是没有添加cc库的依赖啊compile "com.billy.android:cc:0.3.1"
?
日志上显示:找不到ComponentManager类
可参考:https://github.com/luckybilly/CC/blob/master/cc-settings.gradle
@luckybilly 你好,我是有配置的: 此本地的cc-settings.gradle和服务器上的相同,未做修改,所以疑问为何注册不了。
另外一个module中基本相同的配置,但不含greendao,结果是这样:
补充说明,未成功中还有一处不同,是配置的 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }
@currer 能不能去掉greendao的插件测试一下看看?
因为此module是原有的,取消了,报大量错。我试试看先,谢谢。
@luckybilly 你好,两种我进行了测试,发现去掉 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } 就可以了。
确实这样,往test那个之前成功的module中加入上述配置立刻就找不到了:
@currer 好的,谢谢你的反馈,应该是AutoRegister对java8的兼容问题,这两天我找个时间兼容一下
@luckybilly 向您学习了很多,很高兴能够帮助测试出问题,希望您越来越好。
找到原因了:jack编译模式下不兼容TransformAPI
@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
嗦嘎,但我并未设置 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的吧。
@currer AutoRegister V1.1.0已修复此问题,兼容java8
新建module可以创建Component可注册成功并且可以调用成功,但是修改原有的module gradle文件后,却调用始终返回-5,即找不到Component。配置都配置了。不过差异是原有的module里会引用其他的插件例如greendao这样的,是否有影响AutoRegister注册??