0

Im getting the following exception on strict mode when starting my app. Just after my login activity is closed and right before my main activity, which contains a SupportMapFragment, is displayed.

10-29 16:11:22.605: E/StrictMode(1121): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
10-29 16:11:22.605: E/StrictMode(1121): java.lang.Throwable: Explicit termination method 'close' not called
10-29 16:11:22.605: E/StrictMode(1121): at dalvik.system.CloseGuard.open(CloseGuard.java:184)
10-29 16:11:22.605: E/StrictMode(1121): at java.io.RandomAccessFile.<init>(RandomAccessFile.java:128)
10-29 16:11:22.605: E/StrictMode(1121): at maps.d.a.<init>(Unknown Source)
10-29 16:11:22.605: E/StrictMode(1121): at maps.d.b.a(Unknown Source)
10-29 16:11:22.605: E/StrictMode(1121): at maps.m.h.a(Unknown Source)
10-29 16:11:22.605: E/StrictMode(1121): at maps.m.a.a(Unknown Source)
10-29 16:11:22.605: E/StrictMode(1121): at maps.m.u.a(Unknown Source)
10-29 16:11:22.605: E/StrictMode(1121): at maps.k.n.c(Unknown Source)
10-29 16:11:22.605: E/StrictMode(1121): at maps.ao.b.run(Unknown Source)
10-29 16:11:22.605: W/System.err(1121): StrictMode VmPolicy violation with POLICY_DEATH; shutting down.

Its seems related to GoogleMap on the main activity. but what exactly needs to be closed there ? Any thought/idea will be appreciated.

AsafK
  • 2,425
  • 3
  • 32
  • 38

3 Answers3

2

add this method:

public static void enableStrictMode(Context context) {
    StrictMode.setThreadPolicy(
    new StrictMode.ThreadPolicy.Builder()
    .detectDiskReads()
    .detectDiskWrites()
    .detectNetwork()
    .penaltyLog()
    .build());
    StrictMode.setVmPolicy(
    new StrictMode.VmPolicy.Builder()
    .detectLeakedSqlLiteObjects()
    .penaltyLog()
    .build());
    }

and enableStrictMode(this); before super.onCreate(savedInstanceState); in onCreate. In my problem this solution help.

edi233
  • 3,511
  • 13
  • 56
  • 97
  • 3
    StrictMode job is to flush these issues out. How does a change to StrictMode configuration as a solution make sense here ? – AsafK Jan 16 '14 at 18:05
  • 1
    @AsafK Are you finding too many errors in your code? Just stop looking. Problem solved. – Dave Jun 04 '14 at 12:21
0

Stacktrace shows only code from Google Maps Android API v2, so you will not be able to do much about the root cause of it.

I suggest posting a issue on gmaps-api-issues with this bug.

In the meantime disable this kind of check in strict mode.

MaciejGórski
  • 22,187
  • 7
  • 70
  • 94
  • Posted - https://code.google.com/p/gmaps-api-issues/issues/detail?id=5992&thanks=5992&ts=1383090620. Thanks. – AsafK Oct 29 '13 at 23:52
0

I had a similar problem when i tried to run my app. The fix was simple: i just had to have internet activated on my phone. Maybe you should have all the resources that your phone is using(eg. GPS, internet) activated when you run the app.

eddiePopescu
  • 65
  • 1
  • 9