Skip to content

Using Lightsaber to inject dependencies into AAR libraries #5

@tpasztor

Description

@tpasztor

Hello!

I have a question regarding using Lightsaber to push dependencies into AAR libraries.

My setup is, I have an application, and several libraries it relies on, in one project, the libraries being submodules.

What I'm doing is, I've wrapped a Lightsaber "Injector" instance into a generic interface, that I've pushed down to the libraries, so that they can then call "injector.injectMembers(this)" to init their @Inject annotated fields.

Which is working fine, as long as I'm in one project, and the libraries are submodules. However, if I build the libraries as AAR-s, and pull them into the app like that, so they are not submodules anymore, the whole thing stops working.

I've checked the "InjectionDispatcher" class in the "transformClassesWithLightsaberForDebug" folder, and it simply doesn't call "membersInjectors.put()" on the classes from the libraries. My guess is that it only scans app source, and not the source coming from AAR-s.

I've tried with a completely runtime injector (https://github.com/zsoltherpai/feather) and the same setup works fine there. However I really like the fact that Lightsaber doesn't even compile if there are unsatisfied dependencies, so I'd prefer to stick to your library if possible.

Is there anything else I need to do with my libraries to get them working in AAR form aswell? Or is this a use-case that is not supported?

Thanks for the help in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions