无法在logcat上看到StrictMode的详细信息 - 屏幕旋转时抑制了StrictMode策略违规

时间:2016-11-07 11:57:54

标签: android supportmapfragment android-framelayout android-strictmode

我的问题是,我试图了解这种痕迹的来源:

11-06 22:07:36.593 2744-3492/com.spot.spottester W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation
11-06 22:07:36.594 2744-2744/com.spot.spottester W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation

每次我将屏幕从纵向旋转到横向时,我都会在我的Android Studio logcat上显示这些StrictMode行,反之亦然。我不明白为什么logcat表示"抑制"因为我认为StrictMode在我的主Activity(唯一的)中被激活

@Override
protected void onCreate(Bundle savedInstanceState) {

    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
            .detectAll()
            .penaltyLog()
            .build());

其他信息: 当我使用地图时,我看到这种严格的模式违规,在FrameLayout上使用地图片段

<FrameLayout
    android:id="@+id/mapContainer"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:layout_gravity="center_horizontal"
    android:layout_weight="0.35">

    <fragment
        android:id="@+id/mapFragment"
        class="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</FrameLayout>

其他logcat行

11-07 08:47:39.495 32751-4156/com.spot.spottester I/dalvikvm-heap: Grow heap (frag case) to 15.568MB for 196624-byte allocation

11-07 08:47:40.217 32751-32751/com.spot.spottester I/Google Maps Android API: Google Play services package version: 9877036

谢谢大家!

1 个答案:

答案 0 :(得分:4)

更新:自Google Play Services 10.2.0起修复:

  好消息!现在,您在Google Play Services 10.2中修复了“禁止严格模式策略违规:StrictModeDiskReadViolation”日志的问题。用户设备上安装的Google Play服务APK中的修复程序。

https://code.google.com/p/gmaps-api-issues/issues/detail?id=11077

ORIGINAL:我一直在使用Google Maps片段在logcat中看到这些“抑制严格模式策略违规”消息。 即使我没有在我的应用程序中使用StrictMode,仍然会出现抑制消息。

我认为这可能与10月份谷歌的这个问题修复有关,因为我最近才注意到它:

  

此问题现已在Google Play Services 9.8版本中修复。您   不应再看到Android Maps API中的StrictMode违规行为   在日志中,您应该能够重新启用StrictMode   在你的活动中。

https://code.google.com/p/gmaps-api-issues/issues/detail?id=10170

我的想法是他们通过将它们编写为单个“抑制”行来“固定”大堆栈跟踪输出......但是他们也将其用于非严格模式应用程序。