其他分享
首页 > 其他分享> > android – 无法在logcat上看到StrictMode的详细信息 – 屏幕旋转时抑制了StrictMode策略违规

android – 无法在logcat上看到StrictMode的详细信息 – 屏幕旋转时抑制了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

谢谢大家!

解决方法:

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

Good news! The issue where you were seeing “Suppressed StrictMode policy violation: StrictModeDiskReadViolation” logs is now fixed in Google Play Services 10.2. The fix in the the Google Play Services APK which is installed on your users devices.

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

原文:我也一直在logcat中看到这些“抑制严格模式策略违规”消息 – 使用谷歌地图片段.
即使我没有在我的应用程序中使用StrictMode,仍然会出现抑制消息.

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

This issue is now fixed in the Google Play Services 9.8 release. You
should no longer see StrictMode violations from the Android Maps API
in the logs, and you should therefore be able to re-enable StrictMode
in your Activity.

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

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

标签:android,supportmapfragment,android-strictmode,android-framelayout
来源: https://codeday.me/bug/20190623/1267063.html