Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crash after adding getApplicationContext() method #43

Open
JitainSharma opened this issue Aug 3, 2021 · 0 comments
Open

App crash after adding getApplicationContext() method #43

JitainSharma opened this issue Aug 3, 2021 · 0 comments

Comments

@JitainSharma
Copy link

Android OS 11
Using (Option 2) Using delegates

After setup all the steps the exception is throw by the application (Crash log attached at the end).

This is happening after adding the below method to the base application class:

override fun getApplicationContext(): Context =
      LocaleHelper.onAttach(super.getApplicationContext())

If this method is removed, app loads fine without any exception, but when the language from the Android Settings is changed, it doesn't reflect to the app. Have to close the app by swiping to get the changes.

Crash Log:
2021-08-03 16:54:43.585 25724-25724/com.universaltvplus.android E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.universaltvplus.android, PID: 25724
java.lang.RuntimeException: Unable to get provider androidx.lifecycle.ProcessLifecycleOwnerInitializer: java.lang.ClassCastException: android.app.ContextImpl cannot be cast to android.app.Application
at android.app.ActivityThread.installProvider(ActivityThread.java:8068)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:7599)
at android.app.ActivityThread.handleMakeApplication(ActivityThread.java:7483)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7440)
at android.app.ActivityThread.access$1400(ActivityThread.java:301)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2148)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8506)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1139)
Caused by: java.lang.ClassCastException: android.app.ContextImpl cannot be cast to android.app.Application
at androidx.lifecycle.LifecycleDispatcher.init(LifecycleDispatcher.java:43)
at androidx.lifecycle.ProcessLifecycleOwnerInitializer.onCreate(ProcessLifecycleOwnerInitializer.java:36)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2429)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2399)
at android.app.ActivityThread.installProvider(ActivityThread.java:8063)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:7599) 
at android.app.ActivityThread.handleMakeApplication(ActivityThread.java:7483) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7440) 
at android.app.ActivityThread.access$1400(ActivityThread.java:301) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2148) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:246) 
at android.app.ActivityThread.main(ActivityThread.java:8506) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1139) 

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

No branches or pull requests

1 participant