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.

128 questions
8
votes
5 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,235
  • 2
  • 17
  • 42
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
  • 1,940
  • 1
  • 14
  • 36
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
  • 2,891
  • 2
  • 28
  • 52
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
  • 5,309
  • 2
  • 35
  • 51
7
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
  • 53,978
  • 11
  • 145
  • 225
7
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
  • 30,821
  • 26
  • 115
  • 272
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,548
  • 1
  • 15
  • 24
6
votes
0 answers

StrictMode policy violation: android.os.strictmode.LeakedClosableViolation in my app?

New to Android development and trying out StrictMode on my app for the first time. I noticed the following and would like to know if this is a problem in my app or a library—it’s not readily clear to me. Thank you! D/StrictMode: StrictMode policy…
Bink
  • 1,246
  • 1
  • 16
  • 29
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
  • 526
  • 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
5
votes
1 answer

Detecting forgotten SQLite transaction on Android using StrictMode?

Executing multiple SQL statements without putting them into one transaction is a severe bottleneck (see e.g. http://www.sqlite.org/faq.html#q19). I haven't thoroughly checked how SQLite is configured on Android, but anecdotally I perceived…
jonasb
  • 1,767
  • 16
  • 14
5
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
  • 556
  • 4
  • 16
5
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
  • 13,417
  • 7
  • 75
  • 117
5
votes
1 answer

Strict mode violations list

running adb logcat in the shell i see something like this StrictMode policy violation; ~duration=337 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=23 violation=2 what the policy=23 means ? what is violation=2 ? I was searching for…
Lukap
  • 29,596
  • 60
  • 146
  • 239
4
votes
1 answer

StrictMode prior 2.3

I was googleing the enableing StrictMode prior 2.3 but I couldn't find anything useful. All I found was that StrictMode is introduced in 2.3 and you can use reflection to check if there is strict mode like this try { Class sMode =…
Lukap
  • 29,596
  • 60
  • 146
  • 239
1
2
3
8 9