B3nedikt / restring

Restring is a android library to replace string resources dynamically
Apache License 2.0
317 stars 31 forks source link

Crash on start Android 23 #106

Closed DmitrSP closed 2 years ago

DmitrSP commented 2 years ago

run example-java from source:

Process: dev.b3nedikt.restring.example_java, PID: 6750 java.lang.RuntimeException: Unable to start activity ComponentInfo{dev.b3nedikt.restring.example_java/dev.b3nedikt.restring.example.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.content.res.Resources.updateConfiguration(android.content.res.Configuration, android.util.DisplayMetrics)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 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.content.res.Resources.updateConfiguration(android.content.res.Configuration, android.util.DisplayMetrics)' on a null object reference at dev.b3nedikt.restring.internal.RestringResources.updateConfiguration(RestringResources.kt:209) at android.content.res.Resources.(Resources.java:270) at android.content.res.Resources.(Resources.java:249) at dev.b3nedikt.restring.internal.RestringResources.(RestringResources.kt:30) at dev.b3nedikt.restring.internal.RestringContextWrapper$res$2.invoke(RestringContextWrapper.kt:18) at dev.b3nedikt.restring.internal.RestringContextWrapper$res$2.invoke(RestringContextWrapper.kt:16) at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) at dev.b3nedikt.restring.internal.RestringContextWrapper.getRes(RestringContextWrapper.kt:16) at dev.b3nedikt.restring.internal.RestringContextWrapper.getResources(RestringContextWrapper.kt:21) at android.content.ContextWrapper.getResources(ContextWrapper.java:87) at android.view.ContextThemeWrapper.getResources(ContextThemeWrapper.java:81) at androidx.appcompat.app.AppCompatActivity.getResources(AppCompatActivity.java:607) at android.view.Window.getDefaultFeatures(Window.java:1336) at android.view.Window.(Window.java:480) at com.android.internal.policy.PhoneWindow.(PhoneWindow.java:305) at android.app.Activity.attach(Activity.java:6179) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2350) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  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) 

example - 2022-07-25 13:45:00.194 6906-6906/dev.b3nedikt.restring.example E/AndroidRuntime: FATAL EXCEPTION: main Process: dev.b3nedikt.restring.example, PID: 6906 java.lang.RuntimeException: Unable to start activity ComponentInfo{dev.b3nedikt.restring.example/dev.b3nedikt.restring.example.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.content.res.Resources.updateConfiguration(android.content.res.Configuration, android.util.DisplayMetrics)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 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.content.res.Resources.updateConfiguration(android.content.res.Configuration, android.util.DisplayMetrics)' on a null object reference at dev.b3nedikt.restring.internal.RestringResources.updateConfiguration(RestringResources.kt:209) at android.content.res.Resources.(Resources.java:270) at android.content.res.Resources.(Resources.java:249) at dev.b3nedikt.restring.internal.RestringResources.(RestringResources.kt:30) at dev.b3nedikt.restring.Restring.wrapResources(Restring.kt:137) at dev.b3nedikt.restring.example.ExampleApplication.getResources(ExampleApplication.kt:27) at androidx.appcompat.app.AppCompatDelegateImpl.createOverrideConfigurationForDayNight(AppCompatDelegateImpl.java:2482) at androidx.appcompat.app.AppCompatDelegateImpl.attachBaseContext2(AppCompatDelegateImpl.java:445) at androidx.appcompat.app.AppCompatDelegateWrapper.attachBaseContext2(AppCompatDelegateWrapper.kt:93) at androidx.appcompat.app.AppCompatActivity.attachBaseContext(AppCompatActivity.java:139) at android.app.Activity.attach(Activity.java:6175) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2350) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  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) 

B3nedikt commented 2 years ago

@DmitrSP Just fixed with version 5.2.1 :)

DmitrSP commented 2 years ago

Many thanks, @B3nedikt!