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

在gradle wrapper 5.4.1 compiler 模块自定义注解不生效 #86

Open
vincenlee opened this issue Jan 2, 2021 · 2 comments
Open

Comments

@vincenlee
Copy link

java.lang.RuntimeException: java.lang.ClassNotFoundException: com.sankuai.waimai.router.generated.ServiceLoaderInit
at com.sankuai.waimai.router.components.DefaultLogger.handleError(DefaultLogger.java:80)
at com.example.lee.app.TestApplication$1.handleError(TestApplication.java:108)
at com.sankuai.waimai.router.components.DefaultLogger.fatal(DefaultLogger.java:69)
at com.sankuai.waimai.router.core.Debugger.fatal(Debugger.java:121)
at com.sankuai.waimai.router.service.ServiceLoader$1.doInit(ServiceLoader.java:43)
at com.sankuai.waimai.router.utils.LazyInitHelper.performInit(LazyInitHelper.java:50)
at com.sankuai.waimai.router.utils.LazyInitHelper.ensureInit(LazyInitHelper.java:37)
at com.sankuai.waimai.router.service.ServiceLoader.load(ServiceLoader.java:75)
at com.sankuai.waimai.router.Router.getAllServices(Router.java:217)
at com.sankuai.waimai.router.components.DefaultAnnotationLoader.load(DefaultAnnotationLoader.java:20)
at com.sankuai.waimai.router.components.RouterComponents.loadAnnotation(RouterComponents.java:49)
at com.sankuai.waimai.router.common.PageAnnotationHandler.initAnnotationConfig(PageAnnotationHandler.java:52)
at com.sankuai.waimai.router.common.PageAnnotationHandler$1.doInit(PageAnnotationHandler.java:35)
at com.sankuai.waimai.router.utils.LazyInitHelper.performInit(LazyInitHelper.java:50)
at com.sankuai.waimai.router.utils.LazyInitHelper.ensureInit(LazyInitHelper.java:37)
at com.sankuai.waimai.router.common.PageAnnotationHandler.handle(PageAnnotationHandler.java:57)
at com.sankuai.waimai.router.core.ChainedHandler.next(ChainedHandler.java:55)
at com.sankuai.waimai.router.core.ChainedHandler.handleInternal(ChainedHandler.java:48)
at com.sankuai.waimai.router.core.UriHandler.handle(UriHandler.java:61)
at com.sankuai.waimai.router.core.RootUriHandler.startUri(RootUriHandler.java:100)
at com.sankuai.waimai.router.Router.startUri(Router.java:97)
at com.example.lee.activity.MainActivity.onClick(MainActivity.java:331)
at android.view.View.performClick(View.java:6659)
at android.view.View.performClickInternal(View.java:6631)
at android.view.View.access$3100(View.java:790)
at android.view.View$PerformClick.run(View.java:26187)
at android.os.Handler.handleCallback(Handler.java:907)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
Caused by: java.lang.ClassNotFoundException: com.sankuai.waimai.router.generated.ServiceLoaderInit
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at java.lang.Class.forName(Class.java:378)
at com.sankuai.waimai.router.service.ServiceLoader$1.doInit(ServiceLoader.java:38)
at com.sankuai.waimai.router.utils.LazyInitHelper.performInit(LazyInitHelper.java:50) 
at com.sankuai.waimai.router.utils.LazyInitHelper.ensureInit(LazyInitHelper.java:37) 
at com.sankuai.waimai.router.service.ServiceLoader.load(ServiceLoader.java:75) 
at com.sankuai.waimai.router.Router.getAllServices(Router.java:217) 
at com.sankuai.waimai.router.components.DefaultAnnotationLoader.load(DefaultAnnotationLoader.java:20) 
at com.sankuai.waimai.router.components.RouterComponents.loadAnnotation(RouterComponents.java:49) 
at com.sankuai.waimai.router.common.PageAnnotationHandler.initAnnotationConfig(PageAnnotationHandler.java:52) 
at com.sankuai.waimai.router.common.PageAnnotationHandler$1.doInit(PageAnnotationHandler.java:35) 
at com.sankuai.waimai.router.utils.LazyInitHelper.performInit(LazyInitHelper.java:50) 
at com.sankuai.waimai.router.utils.LazyInitHelper.ensureInit(LazyInitHelper.java:37) 
at com.sankuai.waimai.router.common.PageAnnotationHandler.handle(PageAnnotationHandler.java:57) 
at com.sankuai.waimai.router.core.ChainedHandler.next(ChainedHandler.java:55) 
at com.sankuai.waimai.router.core.ChainedHandler.handleInternal(ChainedHandler.java:48) 
at com.sankuai.waimai.router.core.UriHandler.handle(UriHandler.java:61) 
at com.sankuai.waimai.router.core.RootUriHandler.startUri(RootUriHandler.java:100) 
at com.sankuai.waimai.router.Router.startUri(Router.java:97) 
at com.example.lee.activity.MainActivity.onClick(MainActivity.java:331) 
at android.view.View.performClick(View.java:6659) 
at android.view.View.performClickInternal(View.java:6631) 
at android.view.View.access$3100(View.java:790) 
at android.view.View$PerformClick.run(View.java:26187) 
at android.os.Handler.handleCallback(Handler.java:907) 
at android.os.Handler.dispatchMessage(Handler.java:105) 
at android.os.Looper.loop(Looper.java:216) 
at android.app.ActivityThread.main(ActivityThread.java:7625) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sankuai.waimai.router.generated.ServiceLoaderInit" on path: DexPathList[[zip file "/data/app/com.example.lee-FHAnS1UDFB1WaRH-DqHcmg==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.lee-FHAnS1UDFB1WaRH-DqHcmg==/lib/arm64, /data/app/com.example.lee-FHAnS1UDFB1WaRH-DqHcmg==/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64, /prets/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at java.lang.Class.classForName(Native Method) 
at java.lang.Class.forName(Class.java:453) 
at java.lang.Class.forName(Class.java:378) 
at com.sankuai.waimai.router.service.ServiceLoader$1.doInit(ServiceLoader.java:38) 
at com.sankuai.waimai.router.utils.LazyInitHelper.performInit(LazyInitHelper.java:50) 
at com.sankuai.waimai.router.utils.LazyInitHelper.ensureInit(LazyInitHelper.java:37) 
at com.sankuai.waimai.router.service.ServiceLoader.load(ServiceLoader.java:75) 
at com.sankuai.waimai.router.Router.getAllServices(Router.java:217) 
at com.sankuai.waimai.router.components.DefaultAnnotationLoader.load(DefaultAnnotationLoader.java:20) 
at com.sankuai.waimai.router.components.RouterComponents.loadAnnotation(RouterComponents.java:49) 
at com.sankuai.waimai.router.common.PageAnnotationHandler.initAnnotationConfig(PageAnnotationHandler.java:52) 
at com.sankuai.waimai.router.common.PageAnnotationHandler$1.doInit(PageAnnotationHandler.java:35) 
at com.sankuai.waimai.router.utils.LazyInitHelper.performInit(LazyInitHelper.java:50) 
at com.sankuai.waimai.router.utils.LazyInitHelper.ensureInit(LazyInitHelper.java:37) 
at com.sankuai.waimai.router.common.PageAnnotationHandler.handle(PageAnnotationHandler.java:57) 
at com.sankuai.waimai.router.core.ChainedHandler.next(ChainedHandler.java:55) 
at com.sankuai.waimai.router.core.ChainedHandler.handleInternal(ChainedHandler.java:48) 
at com.sankuai.waimai.router.core.UriHandler.handle(UriHandler.java:61) 
at com.sankuai.waimai.router.core.RootUriHandler.startUri(RootUriHandler.java:100) 
at com.sankuai.waimai.router.Router.startUri(Router.java:97) 
at com.example.lee.activity.MainActivity.onClick(MainActivity.java:331) 
at android.view.View.performClick(View.java:6659) 
at android.view.View.performClickInternal(View.java:6631) 
at android.view.View.access$3100(View.java:790) 
at android.view.View$PerformClick.run(View.java:26187) 
at android.os.Handler.handleCallback(Handler.java:907) 
at android.os.Handler.dispatchMessage(Handler.java:105) 
at android.os.Looper.loop(Looper.java:216) 

@vincenlee
Copy link
Author

vincenlee commented Jan 2, 2021

检查 transform 下面没有生成 ServiceLoaderInit,只有一个.R的文件,不知道为啥没有生成出来,配置跟demo 一样 还能什么情况可能影响compiler 生成代码? 我这边也出现上面的问题 [WMRouter] GenerateInit: skipped, no service found

@vincenlee
Copy link
Author

vincenlee commented Jan 2, 2021

问题找到了 gradle wrapper 设置为 5.4.1 就生成不了 变为 4.6 就可以 �,原因是 gradle 5.0 为加快java的编译, 跳过的自定义增量编译,需要在compiler项目中增加 annotationProcessor'com.google.auto.service:auto-service:1.0-rc2',我这边fix了这个问题。希望官方还是能跟着升级下gradle版本走一下看看还有没有其他问题。

@vincenlee vincenlee changed the title 绝对的按照配置走的 结果出这么个错误 无语 在gradle wrapper 5.4.1 compiler 模块自定义注解不生效 Jan 3, 2021
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

1 participant