B3nedikt/AppLocale

java.lang.ClassCastException: dev.b3nedikt.app_locale.AppLocaleContextWrapper cannot be cast to android.app.ContextImpl

Closed this issue · 2 comments

2023/02/08 09:36:14.225 : [CRASH] Unable to instantiate receiver androidx.work.impl.background.systemalarm.RescheduleReceiver: java.lang.ClassCastException: dev.b3nedikt.app_locale.AppLocaleContextWrapper cannot be cast to android.app.ContextImpl
2023/02/08 09:36:14.250 : [TRACE] android.app.ActivityThread.handleReceiver(ActivityThread.java:4929)
2023/02/08 09:36:14.265 : [TRACE] android.app.ActivityThread.access$1900(ActivityThread.java:324)
2023/02/08 09:36:14.277 : [TRACE] android.app.ActivityThread$H.handleMessage(ActivityThread.java:2347)
2023/02/08 09:36:14.290 : [TRACE] android.os.Handler.dispatchMessage(Handler.java:106)
2023/02/08 09:36:14.321 : [TRACE] android.os.Looper.loopOnce(Looper.java:226)
2023/02/08 09:36:14.333 : [TRACE] android.os.Looper.loop(Looper.java:313)
2023/02/08 09:36:14.341 : [TRACE] android.app.ActivityThread.main(ActivityThread.java:8855)
2023/02/08 09:36:14.349 : [TRACE] java.lang.reflect.Method.invoke(Native Method)
2023/02/08 09:36:14.355 : [TRACE] com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
2023/02/08 09:36:14.363 : [TRACE] com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

//build.gradle
implementation 'dev.b3nedikt.applocale:applocale:2.0.3'
implementation 'dev.b3nedikt.viewpump:viewpump:4.0.5'
implementation 'dev.b3nedikt.reword:reword:4.0.0'

//App
override fun attachBaseContext(newBase: Context) {
super.attachBaseContext(AppLocale.wrap(newBase))
}

override fun getResources(): Resources {
    return AppLocale.wrap(baseContext).resources
}

//BaseActivity
private val appCompatDelegate: AppCompatDelegate by lazy {
ViewPumpAppCompatDelegate(
baseDelegate = super.getDelegate(),
baseContext = this,
wrapContext = { baseContext -> AppLocale.wrap(baseContext) }
)
}

@Adamo1983 Fixed with version 3.1.0, see Readme on how to use