Kotlin使用第三方库的那些坑

1. ARouter There‘s no route matched! path = 的解决方式

可能以下几种原因

第一种

每个module下都要添加

    compile 'com.alibaba:arouter-api:x.x.x'
    annotationProcessor 'com.alibaba:arouter-compiler:x.x.x'

第二种

如果你的代码是使用的kotlin
应使用的AROUTER_MODULE_NAME赋值方式为


        kapt {
            arguments {
                arg("AROUTER_MODULE_NAME", project.getName())
            }
        }

JAVA的代码则使用官方文档中的方式

        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [AROUTER_MODULE_NAME: project.getName()]
            }
        }

2.Glide 无法生成GlideApp

Failed to find GeneratedAppGlideModule.
You should include an annotationProcessor compile dependency on com.github.bumptech.glide:compiler in your application
and a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored

Failed to find GeneratedAppGlideModule.
You should include an annotationProcessor compile dependency on com.github.bumptech.glide:compiler in your application 
and a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored

第一种原因

com.github.bumptech.glide:compiler:4.13.0 注解库需要放在运行模块下 不能放在依赖中

第二种

annotationProcessor 在kotlin中不知道为什么不生效 换成kapt就可以正常使用了。

猜你喜欢

转载自blog.csdn.net/a940659387/article/details/116913483
今日推荐