mapbox-maps-android
mapbox-maps-android copied to clipboard
android.os.strictmode.DiskWriteViolation
Environment
- Android OS version:
30
(should affect all OS versions) - Devices affected: Emulator (should affect all devices)
- Maps SDK Version:
10.0.0-beta.20
Observed behavior and steps to reproduce
With DiskWrite
policy enabled, app with Maps SDK crashes during first app launch
with(ThreadPolicy.Builder()) {
detectDiskWrites()
penaltyLog()
penaltyDeath()
StrictMode.setThreadPolicy(build())
}
java.lang.RuntimeException: StrictMode ThreadPolicy violation
at android.os.StrictMode$AndroidBlockGuardPolicy.onThreadPolicyViolation(StrictMode.java:1768)
at android.os.StrictMode$AndroidBlockGuardPolicy.lambda$handleViolationWithTimingAttempt$0$StrictMode$AndroidBlockGuardPolicy(StrictMode.java:1687)
at android.os.-$$Lambda$StrictMode$AndroidBlockGuardPolicy$9nBulCQKaMajrWr41SB7f7YRT1I.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: android.os.strictmode.DiskWriteViolation
at android.os.StrictMode$AndroidBlockGuardPolicy.onWriteToDisk(StrictMode.java:1512)
at java.io.UnixFileSystem.createDirectory(UnixFileSystem.java:352)
at java.io.File.mkdir(File.java:1325)
at java.io.File.mkdirs(File.java:1352)
at com.mapbox.maps.MapInitOptionsKt.applyDefaultParams(MapInitOptions.kt:102)
at com.mapbox.maps.ResourceOptionsManager$Companion.getDefault(ResourceOptionsManager.kt:36)
at com.mapbox.maps.ResourcesAttributeParser.parseResourcesOptions(ResourcesAttributeParser.kt:22)
at com.mapbox.maps.MapView.parseTypedArray$sdk_release(MapView.kt:111)
at com.mapbox.maps.MapView.<init>(MapView.kt:82)
at com.mapbox.maps.MapView.<init>(MapView.kt:59)
at com.mapbox.maps.MapView.<init>(MapView.kt:53)
It also might be helpful for maps to enable Strict mode in demo app. Example from the Search SDK: https://github.com/mapbox/mapbox-search-android/blob/develop/MapboxSearch/sample/src/main/java/com/mapbox/search/sample/SampleApplication.kt#L27-L72