glide’s ksp compiler ,use kotlin symbol processor


  • import kotlin symbol processor plugin

    // in root build.gradle
   plugins {
    id '' version "1.6.10-1.0.2" apply false
  • apply kotlin symbol processor plugin in your modules which needs glide’s annotation processor

   // for example,my demo's application module uses glide's annotation processor
   plugins {
       id ''
   //add ksp generated class path into sourceSets
   android {
       sourceSets {
           main {
               java.srcDirs += ['build/generated/ksp/debug/kotlin']
   //add `glide-ksp` using ksp 
   dependencies {
       ksp "com.github.mistletoe5215:glide-ksp:0.0.1"
  • find classes with @GlideModule/@GlideExtension in library module

use ksp options to mark the custom LibraryGlideModules;since in java annotation processor/kapt these classes can be found using RoundEnvironment to find class with @GlideModule annotation; but now in ksp ,we can’t find these classes with using ksp’s Resolver or SymbolProcessorEnvironment.see issue in ksp therefore,i can only put these class’s qualifiedNames into ksp compile args to solve it(so stupid ( :(,any one can help plz push request) they’re split by “|” separator,use key named GlideModule the custom LibraryGlideExtensions,as well,use key named GlideExtension

    //in application's build.gradle convention scope
   ksp {
       arg( "GlideModule","com.mistletoe.glide.ksp.demo.lib.ProgressLibraryGlideModule|com.bumptech.glide.integration.okhttp3.OkHttpLibraryGlideModule")

checking if Glide-KSP proceed successfully

  • make sure the necessary classes are generated ,they are GeneratedAppGlideModuleImpl,GeneratedRequestManagerFactory,GlideApp,GlideOption,GlideRequest,GlideRequests

  • then,call Glide’s init in Application, ,set break points in GeneratedAppGlideModuleImpl,run app as debug mode to see whether it will block in these break points

  • finally,see if it keeps functioning properly,load image as usual


View Github