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

StrictMode严格模式下崩溃 #1591

Open
zrq1060 opened this issue Jan 9, 2025 · 0 comments
Open

StrictMode严格模式下崩溃 #1591

zrq1060 opened this issue Jan 9, 2025 · 0 comments

Comments

@zrq1060
Copy link

zrq1060 commented Jan 9, 2025

报错原因: ClassicsHeader类内236行调用了getSharedPreferences,应该改为在子线程调用。

2025-01-09_14-33

2025-01-09_14-35

报错信息:
java.lang.RuntimeException: StrictMode ThreadPolicy violation
at android.os.StrictMode$AndroidBlockGuardPolicy.onThreadPolicyViolation(StrictMode.java:1875)
at android.os.StrictMode$AndroidBlockGuardPolicy.lambda$handleViolationWithTimingAttempt$0$android-os-StrictMode$AndroidBlockGuardPolicy(StrictMode.java:1789)
at android.os.StrictMode$AndroidBlockGuardPolicy$$ExternalSyntheticLambda1.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7898)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: android.os.strictmode.DiskReadViolation
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1658)
at libcore.io.BlockGuardOs.access(BlockGuardOs.java:74)
at libcore.io.ForwardingOs.access(ForwardingOs.java:128)
at android.app.ActivityThread$AndroidOs.access(ActivityThread.java:7775)
at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:332)
at java.io.File.exists(File.java:829)
at android.app.ContextImpl.getDataDir(ContextImpl.java:2962)
at android.app.ContextImpl.getPreferencesDir(ContextImpl.java:704)
at android.app.ContextImpl.getSharedPreferencesPath(ContextImpl.java:931)
at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:553)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:217)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:217)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:217)
at com.scwang.smart.refresh.header.ClassicsHeader.(ClassicsHeader.java:236)
at com.scwang.smart.refresh.header.ClassicsHeader.(ClassicsHeader.java:76)

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