Karumi / Rosie

Rosie is an Android framework to create applications following the principles of Clean Architecture.
Other
1.82k stars 157 forks source link

Rosie incompatible with android.arch.lifecycle ¿? #94

Closed rubdottocom closed 6 years ago

rubdottocom commented 6 years ago

Hi I'm trying to implement a Lifecycle observer using android arch components and it crashes, seems the cause is RosieApplication, android.arch is unable to get ApplicationContext, so crash because is null.

 java.lang.RuntimeException: Unable to get provider android.arch.lifecycle.ProcessLifecycleOwnerInitializer: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Application.registerActivityLifecycleCallbacks(android.app.Application$ActivityLifecycleCallbacks)' on a null object reference
                                                          at android.app.ActivityThread.installProvider(ActivityThread.java:5156)
                                                          at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
                                                          at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
                                                          at android.app.ActivityThread.-wrap1(ActivityThread.java)
                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                          at android.os.Looper.loop(Looper.java:148)
                                                          at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                       Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Application.registerActivityLifecycleCallbacks(android.app.Application$ActivityLifecycleCallbacks)' on a null object reference
                                                          at android.arch.lifecycle.LifecycleDispatcher.init(LifecycleDispatcher.java:59)
                                                          at android.arch.lifecycle.ProcessLifecycleOwnerInitializer.onCreate(ProcessLifecycleOwnerInitializer.java:35)
                                                          at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
                                                          at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
                                                          at android.app.ActivityThread.installProvider(ActivityThread.java:5153)
                                                          at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748) 
                                                          at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688) 
                                                          at android.app.ActivityThread.-wrap1(ActivityThread.java) 
                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
                                                          at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                          at android.os.Looper.loop(Looper.java:148) 
                                                          at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                          at java.lang.reflect.Method.invoke(Native Method) 
                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

Do you know how can I integrate both parts?

pedrovgs commented 6 years ago

Hi @rubdottocom the current implementation of the framework is not related to the architecture components. Without taking a look at the code I can't see where the issue is. Could you upload an example project reproducing the crash?

rubdottocom commented 6 years ago

RosieTest.zip

I isolated a base Rosie project and seems to work, so should be a problem with my legacy project... I'll continue to investigate.

Thanks

pedrovgs commented 6 years ago

Closing the issue then until we find a better clue about what's going on. Thanks for the example project 😺

mrbalotta commented 5 years ago

Hello, guys! I am facing the same problem with a legacy code. do you have any clue about what is going on?