GlideApp无法生成的问题

2019-03-27  本文已影响0人  zhujunhua

在Glide4.x之后,流式api使用的GlideApp可能发生无法编译生成的问题。

# 这个如果在 lib-module 中,使用 api 'xxx'
implementation 'com.github.bumptech.glide:glide:4.9.0'

#这个annotationProcessor,需要放在 app-module 中
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'

kotlin代码使用如下配置(kapt需要在app-module的build下):

apply plugin: "kotlin-android"
apply plugin: "kotlin-android-extensions"
apply plugin: "kotlin-kapt"
...
android {

} 
dependencies {
    implementation "com.github.bumptech.glide:glide:4.9.0"
    // annotationProcessor "com.github.bumptech.glide:compiler:4.9.0"
    kapt "com.github.bumptech.glide:compiler:4.9.0"
}
...
apply plugin: "com.google.gms.google-services"

另外,

// 这个AppGlideModule需要放在 app-module 中的应用名的包下(比如application id: com.example.glide)
package com.example.glide

@GlideModule
public class MyAppGlideModule extends AppGlideModule {
}

如此,再编译Build->Rebuild Project之后即可使用GlideApp。

上一篇 下一篇

猜你喜欢

热点阅读