ClassCastException: Application object is not my custom application object
问题 Often in Android code we use this pattern of storing data in the Application object and then accessing it via casting as such: ((MyApplicationObject)getApplication()).getDaggerComponent() getApplication() should always be MyApplicationObject because I have specified it in the AndroidManifest.xml . However, when you deploy this code, sometimes it causes a ClassCastException and we get a different object instead. How can this be? What is the correct workaround for this issue? 回答1: Resolved in