Closed tkasymuulu closed 3 years ago
@tkasymuulu This error occurs because you pass in the AppLocale context to evernotes old job lib.
In short there should be something like this in you code:
JobManager.create(...)....
The context you pass here must not be a wrapped context!
Can you post the code of your Application class?
class App: Application() {
override fun onCreate() {
super.onCreate()
ViewPump.init(RewordInterceptor)
if (CacheUtils.getLocal() == "") {
CacheUtils.setLocal(LocaleEnum.RUSSIAN.type)
}
}
override fun attachBaseContext(base: Context?) {
super.attachBaseContext(AppLocale.wrap(base!!))
}
}
abstract class BaseActivity: MvpAppCompatActivity(), BaseView {
private val appCompatDelegate: AppCompatDelegate by lazy {
ViewPumpAppCompatDelegate(
baseDelegate = super.getDelegate(),
baseContext = this,
wrapContext = { baseContext -> AppLocale.wrap(baseContext) }
)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(getLayoutResourceId())
AppLocale.desiredLocale = Locale(CacheUtils.getLocal())
}
protected abstract fun getLayoutResourceId(): Int
override fun getDelegate(): AppCompatDelegate {
return appCompatDelegate
}
fun setLocale(locale: String) {
CacheUtils.setLocal(locale)
AppLocale.desiredLocale = Locale(locale)
updateLng()
}
override fun onResume() {
super.onResume()
updateLng()
}
private fun updateLng() {
val rootView = window.decorView.findViewById<ContentFrameLayout>(android.R.id.content)
Reword.reword(rootView)
}
}
That is interesting, no JobManager here... Can you check your gradle files and your manifest for JobManager?
dependencies {
implementation 'com.evernote:android-job:1.4.2'
}
It might be possible it is a dependency of one of the libs you are using.
JobManager library is missing in gradle file in dependencies. Apparently one of the dependencies uses this library
Hm, then another way to fix this would be removing this line in your Application class:
override fun attachBaseContext(base: Context?) {
super.attachBaseContext(AppLocale.wrap(base!!))
}
from your App class.
So it looks like this:
override fun onCreate() {
super.onCreate()
ViewPump.init(RewordInterceptor)
if (CacheUtils.getLocal() == "") {
CacheUtils.setLocal(LocaleEnum.RUSSIAN.type)
}
}
Overwriting attachBaseContext is only needed here if you want to use the localized context in your Application already, or if you inject the context somewhere with dagger.
Or just try to raise all versions of libs you use, as evernotes JobManager is deprecated, it may have been patched out already from the dependency.
So I will, thanks for the help!
You're welcome, happy debugging ;)
I see this error when I run the application from the studio. When you run the application from your phone, no errors occur.
java.lang.RuntimeException: Unable to start receiver com.evernote.android.job.patched.internal.JobBootReceiver: java.lang.ClassCastException: dev.b3nedikt.app_locale.AppLocaleContextWrapper cannot be cast to android.app.ContextImpl at android.app.ActivityThread.handleReceiver(ActivityThread.java:2732) at android.app.ActivityThread.-wrap14(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421) 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.ClassCastException: dev.b3nedikt.app_locale.AppLocaleContextWrapper cannot be cast to android.app.ContextImpl at android.app.ActivityThread.handleReceiver(ActivityThread.java:2722) at android.app.ActivityThread.-wrap14(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421) 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)