Questions tagged [android-strictmode]

This mode helps a developer to identify potential bugs in an app.

From Android Developer Docs:

StrictMode is a developer tool which detects things you might be doing by accident and brings them to your attention so you can fix them.

StrictMode is most commonly used to catch accidental disk or network access on the application's main thread, where UI operations are received and animations take place. Keeping disk and network operations off the main thread makes for much smoother, more responsive applications. By keeping your application's main thread responsive, you also prevent ANR dialogs from being shown to users.

135 questions
10
votes
6 answers

Android Kotlin coroutine crashing on strict mode

I have created a very simplified version of my issue below. The strict mode is set up with the following policies: StrictMode.setThreadPolicy( StrictMode.ThreadPolicy.Builder() .detectDiskReads() …
Naveed
  • 2,942
  • 2
  • 25
  • 58
9
votes
1 answer

StrictMode: StrictModeDiskReadViolation when creating SharedPreference

I have a project with dagger setup with following provider method: @Module(...) abstract class AppModule { @Module companion object { ... @Provides @Singleton @JvmStatic fun provideSharedPreferences(@AppContext context:…
azizbekian
  • 60,783
  • 13
  • 169
  • 249
8
votes
4 answers

StrictMode complains about InputStream not being closed

I'm getting the following violation reported by StrictMode in Android. 02-05 04:07:41.190: ERROR/StrictMode(15093): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource…
8
votes
2 answers

Opening a sub-activity several times causes an InstanceCountViolation despite being destroyed

I'm working on a project that has a lower level activity called RecordView to display record details such as an image, the date and time it was taken, and the latitude/longitude information. Rather than trying to manipulate the camera to geotag and…
thegrinner
  • 11,546
  • 5
  • 41
  • 64
8
votes
1 answer

StrictMode disk read violation on empty activity's setContentView

I've recently tried to use StrictMode but got a weird violation, so I tried setting up a new 'Empty Activity' project (in Android Studio) and added an Application class as follows (as described in here): public class TestApplication extends…
MikeL
  • 2,756
  • 2
  • 23
  • 41
8
votes
0 answers

StrictMode java.lang.Throwable: Untagged socket detected with AdMob

I am getting the following exception when using StrictMode with AdMob: java.lang.Throwable: Untagged socket detected; use TrafficStats.setThreadSocketTag() to track all network usage at…
Jose Gómez
  • 3,110
  • 2
  • 32
  • 54
8
votes
0 answers

android.os.StrictMode$StrictModeDiskReadViolation: on com.android.server.policy.sec.TspStateManager.updateTspState

When I turn on StrictMode at my Application onCreate(), everything was good, and the issue found fixed. However, I realize there's a bug of StrictMode as per this issue. So I made the workaround (using Handler), and indeed more issue surfaced. I…
Elye
  • 53,639
  • 54
  • 212
  • 474
7
votes
2 answers

StrictMode + Analytics

I am using Google Analytics for Android but after turning on StrictMode I get a lot of message like this: StrictMode policy violation; ~duration=349 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=23 violation=2 at…
Mike Mitterer
  • 6,810
  • 4
  • 41
  • 62
7
votes
0 answers

On Crashlytics enabled, getting resource leaks

Hiii, I have added crashlytics for error reporting and when I enable strict mode, I am getting resource leaks. Any idea where I am wrong, A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on…
Abhishek Patidar
  • 1,557
  • 1
  • 16
  • 25
6
votes
0 answers

Can i get more info out of this strict mode LeakedClosableViolation message?

I just saw a pretty weird message in the logs of my Android app: W/System: A resource failed to call close. So, i turned on Strict mode's "detectLeakedClosableObjects", but i got a stack trace that i can't really make heads or tails of, since it…
Mathias
  • 3,879
  • 5
  • 36
  • 48
6
votes
1 answer

StrictMode: A resource was acquired at attached stack trace but never released

Sometimes I get this SctrictMode Exception: 2019-01-28 14:18:23.073 4597-4615/my.app.package E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. …
Alexey Timokhin
  • 818
  • 9
  • 23
6
votes
1 answer

Adview loadAd() triggering a StrictMode violation

I am trying to add some adds in my application. When I have StrictMode enabled, I get a bunch of policy violations like this one (maybe 6 or 7 of these). Is this normal? 18817-18817/com.xyz.xyz.xyz D/StrictMode: StrictMode policy violation;…
Kamy
  • 586
  • 4
  • 18
6
votes
1 answer

Android StrictMode and heap dumps

When Android's StrictMode detects a leaked object (e.g. activity) violation, it would be helpful if I could capture a heap dump at that moment in time. There's no obvious way, however, to configure it to do this. Does anyone know of some trick…
Jules
  • 14,841
  • 9
  • 83
  • 130
5
votes
3 answers

Android WebView causes StrictMode violation

I'm noticing that StrictMode is complaining quite loudly about WebView creation. Is there any way to improve the startup performance of a WebView object? I'm instantiating from XML in my onCreate() method. webView = (WebView)…
bumbobway
  • 576
  • 4
  • 15
5
votes
1 answer

MapActivity with StrictMode does not work - Help

After reading Tim Bray's post "New Gingerbread API: StrictMode" on the Android developer's blog, I decided to start using it on my projects. I'm hoping to help catch performance problems before they become problems. My problem is that every time I…
Carl G
  • 491
  • 1
  • 5
  • 5
1
2
3
8 9