NoClassDefFoundError: android.app.ANRManagerProxy

后端 未结 2 627
野的像风
野的像风 2021-01-01 11:16

Does anyone know why this happens? I see this crash reported by my app but I have no idea what it is.

java.lang.NoClassDefFoundError: android.app.ANRManagerP         


        
2条回答
  •  太阳男子
    2021-01-01 11:54

    This happens, because

    • your app id doing some heavy work in main (GUI) thread

    and

    • target device has messed up firmware

    Here is a list of devices, where I experienced more frequently the bug - so not only low end devices, be careful you will ignore it :-)

    Lenovo A316i, N5i, V769M , G3 orro, V5, G3, X-2, F-G906, Z350, V10, G910, EVOLVEO StrongPhone D2, A70C, G9006, V13, C3000, n968, SM-T322, H9503, GT-H9503, S5, F1, Lenovo TP-6000, Galaxy Tab SM-T700C ...

    Only thing you can do about this is to make your app responsive. Best way to do so is to use during development and testing Strict Mode, i.e., to do something like this:

    public void onCreate() {
        if (DEVELOPER_MODE) {
            StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
                 .detectDiskReads()
                 .detectDiskWrites()
                 .detectNetwork()   // or .detectAll() for all detectable problems
                 .penaltyLog()
                 .build());
            StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
                 .detectLeakedSqlLiteObjects()
                 .detectLeakedClosableObjects()
                 .penaltyLog()
                 .penaltyDeath()
                 .build());
        }
        super.onCreate();
    }
    

提交回复
热议问题