Skip to content
This repository has been archived by the owner on Jan 9, 2020. It is now read-only.

Extending RosieApplication #59

Closed
sargunv opened this issue Apr 3, 2016 · 4 comments
Closed

Extending RosieApplication #59

sargunv opened this issue Apr 3, 2016 · 4 comments
Labels

Comments

@sargunv
Copy link
Contributor

sargunv commented Apr 3, 2016

The documentation states "If you do not want to use Dependency Injection in your project, you do not need to extend from RosieApplication", but I get a ClassCastException when I don't extend RosieApplication:

Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to com.karumi.rosie.application.RosieApplication
   at com.karumi.rosie.view.RosieAppCompatActivity.injectActivityModules(RosieAppCompatActivity.java:133)
   at com.karumi.rosie.view.RosieAppCompatActivity.onCreate(RosieAppCompatActivity.java:46)
   at me.sargunvohra.android.diningcourts.MainActivity.onCreate(MainActivity.kt:17)
   at android.app.Activity.performCreate(Activity.java:6876)
   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350) 
   at android.app.ActivityThread.access$1100(ActivityThread.java:222) 
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795) 
   at android.os.Handler.dispatchMessage(Handler.java:102) 
   at android.os.Looper.loop(Looper.java:158) 
   at android.app.ActivityThread.main(ActivityThread.java:7229) 
   at java.lang.reflect.Method.invoke(Native Method) 
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
@matbrandao
Copy link

+1

@Serchinastico
Copy link
Contributor

Yup, if we want to provide that functionality properly we should be doing a runtime type check instead of forcing the downcast right away.

@chuchivic
Copy link

If you import the project as a module, you can comment a couple of lines and works perfectly:

RosieActivity.java

@OverRide protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//TODO comentado
/if (shouldInitializeActivityScopeGraph()) {
injectActivityModules();
}
/
int layoutId = getLayoutId();
setContentView(layoutId);
ButterKnife.bind(this);
onPreparePresenter();
//TODO comentado
//presenterLifeCycleLinker.initializeLifeCycle(this, this);
}

RosieApplication.java:

@OverRide public void onCreate() {
super.onCreate();
/initGraph();
injectApplication();
/
}

@pedrovgs
Copy link
Contributor

pedrovgs commented Apr 4, 2016

@sargunster we have just released a new version with the fix. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants