3

We've been lately seeing the following stack trace in our developer console, uniquely reported for Huawei devices running Android 10 (Huawei HUAWEI P smart 2019 (HWPOT-H), 2816MB RAM, Android 10 to be precise):

java.lang.IllegalStateException: 
  at android.os.Parcel.createException (Parcel.java:2079)
  at android.os.Parcel.readException (Parcel.java:2039)
  at android.os.Parcel.readException (Parcel.java:1987)
  at android.os.INetworkManagementService$Stub$Proxy.setUidCleartextNetworkPolicy (INetworkManagementService.java:2754)
  at android.os.StrictMode.setVmPolicy (StrictMode.java:1974)
  at android.os.StrictMode.initVmDefaults (StrictMode.java:1414)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:6923)
  at android.app.ActivityThread.access$2200 (ActivityThread.java:292)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2195)
  at android.os.Handler.dispatchMessage (Handler.java:107)
  at android.os.Looper.loop (Looper.java:213)
  at android.app.ActivityThread.main (ActivityThread.java:8147)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:513)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1101)
Caused by: android.os.RemoteException: 
  at com.android.server.NetworkManagementService.applyUidCleartextNetworkPolicy (NetworkManagementService.java:1577)
  at com.android.server.NetworkManagementService.setUidCleartextNetworkPolicy (NetworkManagementService.java:1612)
  at android.os.INetworkManagementService$Stub.onTransact (INetworkManagementService.java:1319)
  at com.android.server.HwNetworkManagementService.onTransact (HwNetworkManagementService.java:886)
  at android.os.Binder.execTransactInternal (Binder.java:1028)

I've traced it back - if I understood correctly - to the fact that we are using StrictMode on our app.

        val strictModeVMPolicyBuilder = StrictMode.VmPolicy.Builder()
                .detectActivityLeaks()
                .detectLeakedSqlLiteObjects()
                .detectLeakedClosableObjects()


        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            strictModeVMPolicyBuilder.detectCleartextNetwork()
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            strictModeVMPolicyBuilder.detectContentUriWithoutPermission()
        }


        StrictMode.setVmPolicy(strictModeVMPolicyBuilder
                .penaltyLog()
                .build())

What baffles me is that is is causing/reporting an Exception, though I would expect that it would just log the penalty. Is this an OS bug or is there a way to mitigate the issue?

Thanks for the info!

Kvandermast
  • 106
  • 4
  • 1
    Most likely, this is a bug in Huawei's modifications to Android. "We've been lately seeing the following stack trace in our developer console" -- you should be disabling `StrictMode` entirely for a production app. Use it only for development builds. – CommonsWare Mar 13 '20 at 10:48
  • Thanks @CommonsWare, +1. I disabled it for a future build. It shows that a pure Android image is always better I would say. – Kvandermast Mar 13 '20 at 11:09
  • 1
    I started getting the exact same error on my Pixel 3 XL - still crashes despite disabling `StrictMode`. – scana Apr 26 '21 at 11:02
  • @scana Same here. It drove me crazy. I tried everything from clean/rebuild, invalidate caches, restarting the IDE, and more. Uninstalling the app from the Pixel 3 and then reinstalling finally solved it. – user1114 Apr 26 '21 at 15:30
  • I encountered the same problem: solution was to reboot the device (a FairPhone 3+) – Pascal Mar 04 '23 at 15:15

0 Answers0