The toothpick-reflect artifact is an API-compatible implementation of Toothpick 1.x which uses 100% reflection instead of annotation processing for use during development.
-
Add
jcenter()
maven repository:repositories { ... jcenter() }
-
Use
reflect-runtime
artifact for IDE builds:dependencies { if (properties.containsKey('android.injected.invoked.from.ide')) { implementation 'com.lukaville.toothpick.reflect:toothpick-reflect-runtime:0.1.0' } else { implementation 'com.github.stephanenicolas.toothpick:toothpick-runtime:1.1.3' kapt 'com.github.stephanenicolas.toothpick:toothpick-compiler:1.1.3' } }
* replace
kapt
withannotationProcessor
for Java modules -
If you are using factory registries and member injector registries you need to instanciate them using reflection:
-
FactoryRegistryLocator.setRootRegistry(FactoryRegistry()); MemberInjectorRegistryLocator.setRootRegistry(MemberInjectorRegistry());
-
FactoryRegistryLocator.setRootRegistry(Class.forName("mypackage.FactoryRegistry").getConstructor().newInstance()); MemberInjectorRegistryLocator.setRootRegistry(Class.forName("mypackage.MemberInjectorRegistry").getConstructor().newInstance());
Also, if you are using obfuscation you need to keep names for the registries so reflective instantiation doesn't fail.
-
@ProvidesSingletonInScope
annotation is not supported because it's not available at runtime, useprovidesSingletonInScope()
binding instead. It can be fixed in the future by monkey-patching this annoation- Superclass member injection is not implemented for dependencies created using factories (see FactoryGenerator.java)
- This implementation may contain bugs, please do not use for production