Search code examples
javaandroidandroid-glidedaggerautofactory

Factories generated with auto-factory cant import glide generated api


I'm using auto-factory and the glide generated api. The classes generated by auto-factory use the GlideRequests class which is generated by the GlideModule but when the build is finished, GlideRequests is not imported in the generated factory class.

It's as if Glide is generating it's classes after auto-factory does its thing.

Any ideas how this can be solved? Maybe changing the build/generating order?

Thank you.


Solution

  • A fix is to use the fully qualified class name in the constructor of SomeClass. So instead of

    @AutoFactory
    public class SomeClass {
    
      SomeClass(@Provided AnotherClassFactory anotherClassFactory,
                @Provided SomeDependency someDependency,
                int someValue) {
        ...
      }
    }
    

    use

    @AutoFactory
    public class SomeClass {
    
      SomeClass(@Provided com.fully.qualifiedpath.AnotherClassFactory anotherClassFactory,
                @Provided SomeDependency someDependency,
                int someValue) {
        ...
      }
    }
    

    more details here : https://github.com/google/auto/issues/124