Here's my code, which I based on some old tutorial found on the internet. There really should be some examples on the main site of Dagger 2, I found it really difficult to understand how to implement all this.
It's really a lot of work to get such a simple app to run. I have two questions:
Do I have to call DaggerLoggerComponent in every class I want to get some components like my Logger class?
Also how can I make the scope of the Logger class a singleton? Right now every button click creates a new logger instance.
Probably I dont understand some underlying concepts, I've only used dependency injection in Spring before and all of this seems strange to me.
public class MainActivity extends AppCompatActivity {
private Button button;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
init();
}
private void init(){
button = (Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
LoggerComponent component = DaggerLoggerComponent.builder().loggerModule(new LoggerModule()).build();
component.getLogger().log("Hello!",MainActivity.this);
}
});
}
}
public class Logger {
private static int i = 0;
public Logger(){
i++;
}
public static int getI() {
return i;
}
public void log(String text, Context context){
Toast.makeText(context,text+" "+i,Toast.LENGTH_SHORT).show();
}
}
#Singleton
#Component(modules={LoggerModule.class})
public interface LoggerComponent {
Logger getLogger();
}
#Module
public class LoggerModule {
#Provides
#Singleton
Logger provideLogger(){
return new Logger();
}
}
The answer is
public class MainActivity extends AppCompatActivity {
#OnClick(R.id.button) //ButterKnife
public void onClickButton() {
logger.log("Hello!");
}
#Inject
Logger logger;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Injector.INSTANCE.getApplicationComponent().inject(this);
ButterKnife.bind(this);
}
#Override
protected void onDestroy() {
ButterKnife.unbind(this);
super.onDestroy();
}
}
public class Logger {
private static int i = 0;
private CustomApplication customApplication;
public Logger(CustomApplication application) {
this.customApplication = application;
i++;
}
public static int getI() {
return i;
}
public void log(String text){
Toast.makeText(customApplication, text + " " + i,Toast.LENGTH_SHORT).show();
}
}
public interface LoggerComponent {
Logger logger();
}
#Module
public class ApplicationModule {
private CustomApplication customApplication;
public ApplicationModule(CustomApplication customApplication) {
this.customApplication = customApplication;
}
#Provides
public CustomApplication customApplication() {
return customApplication;
}
}
#Module
public class LoggerModule {
#Provides
#Singleton
Logger provideLogger(){
return new Logger();
}
}
#Singleton
#Component(modules={LoggerModule.class, ApplicationModule.class})
public interface ApplicationComponent extends LoggerComponent {
CustomApplication customApplication();
void inject(MainActivity mainActivity);
}
public class CustomApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
Injector.INSTANCE.initializeApplicationComponent(this);
}
}
public enum Injector {
INSTANCE;
private ApplicationComponent applicationComponent;
public ApplicationComponent getApplicationComponent() {
return applicationComponent;
}
void initializeApplicationComponent(CustomApplication customApplication) {
this.applicationComponent = DaggerApplicationComponent.builder()
.applicationModule(new ApplicationModule(customApplication))
.build();
}
}
This is currently our Dagger2 architecture.
EDIT: This is from our actual code for Retrofit stuff from our application we're making:
public interface RecordingService {
ScheduledRecordsXML getScheduledRecords(long userId)
throws ServerErrorException;
}
public class RecordingServiceImpl
implements RecordingService {
private static final String TAG = RecordingServiceImpl.class.getSimpleName();
private RetrofitRecordingService retrofitRecordingService;
public RecordingServiceImpl(RetrofitRecordingService retrofitRecordingService) {
this.retrofitRecordingService = retrofitRecordingService;
}
#Override
public ScheduledRecordsXML getScheduledRecords(long userId)
throws ServerErrorException {
try {
return retrofitRecordingService.getScheduledPrograms(String.valueOf(userId));
} catch(RetrofitError retrofitError) {
Log.e(TAG, "Error occurred in downloading XML file.", retrofitError);
throw new ServerErrorException(retrofitError);
}
}
}
#Module
public class NetworkClientModule {
#Provides
#Singleton
public OkHttpClient okHttpClient() {
OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.interceptors().add(new HeaderInterceptor());
return okHttpClient;
}
}
#Module(includes = {NetworkClientModule.class})
public class ServiceModule {
#Provides
#Singleton
public RecordingService recordingService(OkHttpClient okHttpClient, Persister persister, AppConfig appConfig) {
return new RecordingServiceImpl(
new RestAdapter.Builder().setEndpoint(appConfig.getServerEndpoint())
.setConverter(new SimpleXMLConverter(persister))
.setClient(new OkClient(okHttpClient))
.setLogLevel(RestAdapter.LogLevel.NONE)
.build()
.create(RetrofitRecordingService.class));
}
//...
}
public interface RetrofitRecordingService {
#GET("/getScheduledPrograms")
ScheduledRecordsXML getScheduledPrograms(#Query("UserID") String userId);
}
public interface ServiceComponent {
RecordingService RecordingService();
//...
}
public interface AppDomainComponent
extends InteractorComponent, ServiceComponent, ManagerComponent, ParserComponent {
}
#Singleton
#Component(modules = {
//...
InteractorModule.class,
ManagerModule.class,
ServiceModule.class,
ParserModule.class
//...
})
public interface ApplicationComponent
extends AppContextComponent, AppDataComponent, AppDomainComponent, AppUtilsComponent, AppPresentationComponent {
void inject(DashboardActivity dashboardActivity);
//...
}
Do I have to call DaggerLoggerComponent in every class I want to get some components like my Logger class?
Yes for all classes that created by the system like Application, Activity and Service. but for you own classes, you don't need that. just annotate you constructor with #inject and dagger will provide your dependencies.
Also how can I make the scope of the Logger class a singleton? Right
now every button click creates a new logger instance.
Your setup for singleton is correct. but you have to initialize the component one time after the activity is created (onCreate) in order to let dagger to inject all fields. Also you can utilize lazy injection feature if you don't need the Logger object right away.
#Inject
Logger logger;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LoggerComponent component = DaggerLoggerComponent.builder().loggerModule(new LoggerModule()).build();
component.inject(this);
init();
}
Then you can access your object without take the reference from the component:
private void init(){
button = (Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
logger.log("Hello!",MainActivity.this);
}
});
}
In summary:
You have to initialize the component in all classes that use field injections.
UPDATE:
To do the actual injection, you have to declare inject() method into your component and dagger will automatically implement it. This method will take care of provide any object annotated with #Inject.
Related
My AppComponent
#Singleton
#Component(modules = {SplashModule.class})
public interface AppComponent {
void inject(SplashActivity splashActivity);//this is inject activity
}
Splash Module
#Module
public class SplashModule {
#Provides
#Singleton
static SplashInteract provideSplashInteract(){
return new SplashInteract();//instance interact
};
#Provides
#Singleton
SplashPresenter provideSplashPresenter(SplashInteract splashInteract){
return new SplashPresenter(splashInteract);//instance SplashPresenter
};
}
Splash Presenter
public class SplashPresenter implements ISplashContract.Presenter {
ISplashContract.View mView;
SplashInteract splashInteract;
public SplashPresenter(SplashInteract splashInteract) {
this.splashInteract =splashInteract;
}
public void bindView(ISplashContract.View mView) {
this.mView = mView;
}
#Override
public void attach() {
this.mView.startAnimation();//start splash animation
}
#Override
public void start(Activity activity) {
this.splashInteract.SplashScreenAnimation(activity);// add interact methods
}
}
Splash Activity
public class SplashActivity extends AppCompatActivity implements ISplashContract.View{
#Inject SplashPresenter splashPresenter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
getAppComponent().inject(this);//call BaseApp DaggerAppComponent
splashPresenter.attach();
splashPresenter.bindView(this);
}
#Override
public void startAnimation() {
this.splashPresenter.start(this);
}
}
Base App
public class BaseApp extends Application {
private static AppComponent appComponent;
#Override
public void onCreate() {
super.onCreate();
setUp();
}
private void setUp() {
appComponent = DaggerAppComponent.builder().build();//Call Component in BaseApp
}
public static AppComponent getAppComponent() {
return appComponent;
}
}
Hi Everyone
I am writing a project, I want to use dagger, but I am inexperienced at this. This code gives a NullPointerException error. I could not find what I am doing wrong.
I need help and I will be glad if those who know better than the dagger guide me
In your case, dagger will not know how to provide splashPresenter, either do a constructor Injection or define in the module how SplashPresenter should be created, and remove SpashPresenter from the Component. The module approach should be like so,
#Module
public class SplashModule {
ISplashContract.View mView;
public SplashModule(ISplashContract.View mView) {
this.mView = mView;//add SplashModule view
}
#Provides
#Singleton
public ISplashContract.View provideSplashPresenter(){
return mView;//set this view
}
#Provides
static SplashInteract provideSplashInteract(){
return new SplashInteract();//instance interact
};
#Provides
SplashPresenter provideSplashPresenter(ISplashContract.View mView, SplashInteract splashInteract){
return new SplashPresenter(mView, splashInteract);//instance SplashPresenter
};
}
And remove inject annotations from SplashPresenter and you will also have to change the signature for its constructor. You can optionally remove Singleton annotation from the code, if the presenter is not supposed to be singleton.
Updates based on comments
public class SplashModule {
#Provides
static SplashInteract provideSplashInteract(){
return new SplashInteract();//instance interact
};
#Provides
SplashPresenter provideSplashPresenter(SplashInteract splashInteract){
return new SplashPresenter(splashInteract);//instance SplashPresenter
};
}
public class SplashPresenter implements ISplashContract.Presenter {
ISplashContract.View mView;
SplashInteract splashInteract;
public SplashPresenter(SplashInteract splashInteract) {
this.splashInteract = splashInteract;
}
public void bindView(ISplashContract.View mView) {
this.mView = mView;
}
#Override
public void attach() {
this.mView.startAnimation();//start splash animation
}
#Override
public void start(Activity activity) {
this.splashInteract.SplashScreenAnimation(activity);// add interact methods
}
}
public class SplashActivity extends AppCompatActivity implements ISplashContract.View{
#Inject SplashPresenter splashPresenter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
getAppComponent().inject(this);//call BaseApp DaggerAppComponent
splashPresenter.bind("the view you want to bind")
splashPresenter.attach();
}
#Override
public void startAnimation() {
this.splashPresenter.start(this);
}
}```
Make sure that you declare your BaseApp in AndroidManifest :
<application
android:name=".fullPathTo.BaseApp"
...
I'm trying to figure how to deal with dependency injection with dagger 2 and clean architecture in Android. What i want to achieve is when i click a button, a message will be saved to Firebase Database. And show success message to user. When i build my project i'm getting this error:
Error:(10, 1) error: com.example.mvpsample.home.HomeComponent
(unscoped) may not reference scoped bindings: #Provides #Singleton
com.google.firebase.database.FirebaseDatabase
com.example.mvpsample.data.DataModule.provideFirebaseDatabase()
Here my app class:
public class MyApp extends Application {
private static MyApp app;
private HomeComponent homeComponent;
private AuthenticationComponent authenticationComponent;
#Inject
Presenter presenter;
#Override
public void onCreate() {
super.onCreate();
app = this;
homeComponent = DaggerHomeComponent
.builder()
.homeModule(new HomeModule(presenter.getView()))
.build();
}
public HomeComponent getHomeComponent() {
return homeComponent;
}
public static MyApp app() {
return app;
}
}
HomeActivity
public class HomeActivity extends AppCompatActivity implements BaseContract.View {
#Inject
public Presenter presenter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
MyApp
.app()
.getHomeComponent()
.inject(this);
}
#OnClick(R.id.tvHello)
public void clickTvHello() {
presenter.writeStringToDatabase("Hi");
}
#Override
public void showSuccessMessage() {
Toast.makeText(this, "Success", Toast.LENGTH_SHORT).show();
}
}
HomeModule
#Module
public class HomeModule {
private final BaseContract.View View;
#Inject
public HomeModule(BaseContract.View View) {
this.View = View;
}
#Provides
public BaseContract.View provideView() {
return View;
}
}
HomeComponent
#Component(modules = {HomeModule.class, DataModule.class})
public interface HomeComponent {
void inject(HomeActivity homeActivity);
}
DataModule
#Module
public class DataModule {
#Provides
#Singleton
public FirebaseDatabase provideFirebaseDatabase() {
return FirebaseDatabase.getInstance();
}
}
BaseContract
public interface BaseContract {
interface View {
void showSuccessMessage();
}
interface Presenter {
View getView();
void writeStringToDatabase(String string);
}
}
Presenter
public class Presenter implements BaseContract.Presenter {
private final BaseContract.View View;
#Inject
FirebaseDatabase firebaseDatabase;
#Inject
public Presenter(BaseContract.View View) {
this.View = View;
}
#Override
public BaseContract.View getView() {
return View;
}
#Override
public void writeStringToDatabase(String string) {
firebaseDatabase.getReference()
.child("messages")
.push()
.child("value")
.setValue(string).addOnSuccessListener(new OnSuccessListener<Void>() {
#Override
public void onSuccess(Void aVoid) {
getView().showSuccessMessage();
}
});
}
}
I followed sample projects and tutorials but did not understand what i'm doing wrong here. Not looking for working project but i want to learn what is best practice of this and how to manage and use modules and components.
The problem is that your HomeComponent is not scoped while your DataModule provides a scoped dependency (i.e the FirebaseDatabase dependency).
A non-scoped component cannot rely on scoped provider. You either have to remove the #Singleton on your provideFirebaseDatabase() provider or add #Singleton on your HomeComponent.
I am trying to inject dependencies into my App. Everything is working fine until I tried to inject Realm into my Service class. I started getting IllegalStateException which is obviously caused by me accessing Realm from a Thread it was created. So, this is the structure of my Dependency Injection
The AppModule
#Module
public class AppModule {
MainApplication mainApplication;
public AppModule(MainApplication mainApplication) {
this.mainApplication = mainApplication;
}
#Provides
#Singleton
MainApplication getFmnApplication() {
return mainApplication;
}
}
The RequestModule
#Module
public class RequestModule {
#Provides
#Singleton
Retrofit.Builder getRetrofitBuilder() {
return new Retrofit.Builder()
.baseUrl(BuildConfig.HOST)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create(CustomGsonParser.returnCustomParser()));
}
#Provides
#Singleton
OkHttpClient getOkHttpClient() {
return new OkHttpClient.Builder()
.addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC))
.connectTimeout(30000, TimeUnit.SECONDS)
.readTimeout(30000, TimeUnit.SECONDS).build();
}
#Provides
#Singleton
Retrofit getRetrofit() {
return getRetrofitBuilder().client(getOkHttpClient()).build();
}
#Provides
#Singleton
ErrorUtils getErrorUtils() {
return new ErrorUtils();
}
#Provides
#Singleton
MainAPI getMainAPI() {
return getRetrofit().create(MainAPI.class);
}
// Used in the Service class
#Provides
#Singleton
GeneralAPIHandler getGeneralAPIHandler(MainApplication mainApplication) {
return new GeneralAPIHandler(mainApplication, getMainAPIHandler(), getErrorUtils());
}
}
The AppComponent
#Singleton
#Component(modules = {
AppModule.class,
RequestModule.class
})
public interface MainAppComponent {
void inject(SyncService suncService);
}
The Application Class
public class MainApplication extends Application {
private MainAppComponent mainAppComponent;
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
#Override
public void onCreate() {
super.onCreate();
mainAppComponent = DaggerMainAppComponent.builder()
.appModule(new AppModule(this))
.requestModule(new RequestModule())
.build();
}
public MainAppComponent getMainAppComponent() {
return mainAppComponent;
}
}
GeneralAPIHandler
public class GeneralAPIHandler {
private static final String TAG = "GeneralAPIHandler";
private MainAPI mainAPI;
private Realm realm;
private ErrorUtils errorUtils;
private Context context;
public GeneralAPIHandler() {
}
public GeneralAPIHandler(MainApplication mainApplication, MainAPI mainAPI, ErrorUtils errorUtils) {
this.mainAPI = mainAPI;
this.realm = RealmUtils.getRealmInstance(mainApplication.getApplicationContext());
this.errorUtils = errorUtils;
this.context = mainApplication.getApplicationContext();
}
public void sendPayload(APIRequestListener apiRequestListener) {
List<RealmLga> notSentData = realm.where(RealmLga.class).equalTo("isSent", false).findAll(); <-- This is where the error comes from
.... Other code here
}
}
This only happens when I'm calling it from a Service class But, it was created with the Application Context. Why is it throwing an IllegalStateException
The Service Class
public class SyncService extends IntentService {
#Inject GeneralAPIHandler generalAPIHandler;
#Override
public void onCreate() {
super.onCreate();
((MainApplication) getApplicationContext()).getMainAppComponent().inject(this);
}
/**
* Creates an IntentService. Invoked by your subclass's constructor.
*/
public SyncService() {
super("Sync");
}
#Override
protected void onHandleIntent(Intent intent) {
sendInformations();
}
private void sendInformations() {
generalAPIHandler.sendPayload(new APIRequestListener() {
#Override
public void onError(APIError apiError){}
#Override
public void didComplete(WhichSync whichSync){}
})
}
}
Any help on what I'm doing wrong to be making Realm throw IllegalStateException would be appreciated. Thanks
#Inject GeneralAPIHandler generalAPIHandler;
#Override
public void onCreate() {
super.onCreate();
((MainApplication) getApplicationContext()).getMainAppComponent().inject(this);
}
And therefore
public GeneralAPIHandler(MainApplication mainApplication, MainAPI mainAPI, ErrorUtils errorUtils) {
this.mainAPI = mainAPI;
this.realm = RealmUtils.getRealmInstance(mainApplication.getApplicationContext()); // <--
This code runs on the UI thread
#Override
protected void onHandleIntent(Intent intent) {
sendInformations();
}
private void sendInformations() {
generalAPIHandler.sendPayload(new APIRequestListener() {
....
public void sendPayload(APIRequestListener apiRequestListener) {
List<RealmLga> notSentData = realm.where(RealmLga.class).equalTo("isSent", false).findAll();
This code runs on the IntentService background thread
You also wouldn't be closing the Realm instance despite being on a non-looping background thread anyways, so it did you a favor by crashing.
Solution, you should obtain Realm instance in onHandleIntent(), and close it in finally { at the end of execution.
You might say, "but then how will I mock my Constructor argument", the answer is use a class like
#Singleton
public class RealmFactory {
#Inject
public RealmFactory() {
}
public Realm create() {
return Realm.getDefaultInstance();
}
}
a realm instance needs to be accessed only from the thread it's created in.
Your intent service runs in a background thread. Your realm was likely created on the main thread
I'm trying to write some tests for fragments which have fields annotated with #Inject. For example, a chunk of my app looks like this:
Module:
#Module
public class PdfFactoryModule {
#Provides #Singleton
PdfFactory providePdfFactory() {
return PdfFactory.getPdfFactory();
}
}
Component:
#Singleton
#Component(modules = PdfFactoryModule.class)
public interface CorePdfComponent {
void inject(PagerFragment pagerFragment);
}
Application:
public class CorePdfApplication extends Application {
#NonNull
private CorePdfComponent component;
#Override
public void onCreate() {
super.onCreate();
component = DaggerCorePdfComponent.builder().build();
}
#NonNull
public CorePdfComponent getComponent() {
return component;
}
}
PagerFragment:
public class PagerFragment extends Fragment {
#Inject PdfFactory pdfFactory;
#Override
public void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Dagger 2
((CorePdfApplication) getActivity().getApplication()).getComponent().inject(this);
}
(Note that these are only snippets of my whole code, I'm showing only the essentials for this particular dependency to keep it clear.)
I was trying to do a test like this:
Fake Module:
#Module
public class FakePdfFactoryModule extends PdfFactoryModule {
#Override
PdfFactory providePdfFactory() {
return Mockito.mock(PdfFactory.class);
}
}
Fake Component:
#Singleton
#Component(modules = FakePdfFactoryModule.class)
public interface FakeCorePdfComponent extends CorePdfComponent {
void inject(PagerFragmentTest pagerFragmentTest);
}
Fake Application:
public class FakeCorePdfApplication extends CorePdfApplication {
#NonNull
private FakeCorePdfComponent component;
#Override
public void onCreate() {
super.onCreate();
component = DaggerFakeCorePdfComponent.builder().build();
}
#NonNull
public FakeCorePdfComponent getComponent() {
return component;
}
}
Test:
#RunWith(RobolectricTestRunner.class)
#Config(constants = BuildConfig.class, sdk = 21, application = FakeCorePdfApplication.class)
public class PagerFragmentTest {
PagerFragment pagerFragment;
#Before
public void setup() {
pagerFragment = new PagerFragment();
startVisibleFragment(pagerFragment);
}
#Test
public void exists() throws Exception {
assertNotNull(pagerFragment);
}
But the DaggerFakeCorePdfComponent doesn't generate. I may have messed up big time because I never tested with dependency injection. What am I doing wrong?
My advice - "Do not use dagger in tests".
Just change your code to next:
public class FakeCorePdfApplication extends CorePdfApplication {
#NonNull
private CorePdfComponent component = mock(CorePdfComponent.class);
#Override
public void onCreate() {
super.onCreate();
}
#NonNull
public CorePdfComponent getComponent() {
return component;
}
}
And:
#RunWith(RobolectricTestRunner.class)
#Config(constants = BuildConfig.class, sdk = 21, application = FakeCorePdfApplication.class)
public class PagerFragmentTest {
PagerFragment pagerFragment;
#Before
public void setup() {
pagerFragment = new PagerFragment();
CorePdfComponent component = ((CorePdfApplication)RuntimeEnvironment.application).getComponent();
doAnswer( new Answer() {
Object answer(InvocationOnMock invocation) {
fragment. pdfFactory = mock(PdfFactory.class);
return null;
}
}).when(component).inject(pageFragment);
startVisibleFragment(pagerFragment);
}
#Test
public void exists() throws Exception {
assertNotNull(pagerFragment);
}
}
You may try:
androidTestApt "com.google.dagger:dagger-compiler:<version>"
I was having similar problem, it worked for me.
Hello so I've been going crazy trying to figure out what I haven't configured properly to get a non null dependency when injecting into a class. Below is my current code
public interface DaggerGraph {
void inject(SplashActivity splashActivity);
}
DaggerGraph to provide interface for injecting
#Singleton
#Component(modules = {MainModule.class})
public interface DaggerComponent extends DaggerGraph {
final class Initializer {
private Initializer() {
}
public static DaggerComponent init(Application app) {
return DaggerDaggerComponent.builder()
.mainModule(new MainModule(app))
.build();
}
}
}
The Dagger component
#Module
public class MainModule {
private final Application app;
public MainModule(Application app) {
this.app = app;
}
#Provides
#Singleton
Application provideApplication() {
return app;
}
#Provides
#Singleton
Resources provideResources() {
return app.getResources();
}
}
The Main Module
public class App extends Application {
private static DaggerComponent daggerComponent;
#Override
public void onCreate() {
super.onCreate();
daggerComponent = DaggerComponent.Initializer.init(this);
}
public static DaggerComponent component() {
return daggerComponent;
}
}
Application
public class SplashActivity extends BaseActivity {
#Inject
Resources resources;
#Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
App.component().inject(this);
}
#Override
protected void onResume() {
super.onResume();
Timber.d(Boolean.toString(resources == null)); //Always true
}
}
In this activity Resources is ALWAYS null and its driving me crazy. Any help is much appreciated.