This project showcases various use-cases of dependency-injection using Dagger >= 2.11.
AndroidManifest.xml
refers to theApplication
-class<application android:name=".App"
Application
-class extends fromDaggerApplication
public class App extends DaggerApplication
@dagger.Component
(insideApplication
-class or in a separate file) must contain moduleAndroidSupportInjectionModule.class
@dagger.Component(modules = {AndroidSupportInjectionModule.class}) interface Component extends AndroidInjector<App> { @dagger.Component.Builder abstract class Builder extends AndroidInjector.Builder<App> {} }
Application
-class must@Override
the methodapplicationInjector()
The class@Override protected AndroidInjector<? extends DaggerApplication> applicationInjector() { return DaggerApp_Component .builder() .create(this); }
DaggerApp_Component
will be generated automatically by the annotationProcessor.
If not, try building the project and try again.
If it's still not working there's something wrong.
Copyright 2017 Jan Grünewald
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.