I get the error message when I launch Layout Inspector: "Error obtaining view hierarchy: Unexpected error: empty view hierarchy".
Also in Logcat there is an exception:
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater I/art: Exception thrown by dispatcher for 0x56555254
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: java.lang.NoClassDefFoundError: android.graphics.drawable.Icon
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at libcore.reflect.InternalNames.getClass(InternalNames.java:55)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at java.lang.Class.getDexCacheType(Class.java:479)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at java.lang.reflect.ArtMethod.getDexCacheType(ArtMethod.java:236)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at java.lang.reflect.ArtMethod.getParameterTypes(ArtMethod.java:176)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at java.lang.reflect.Method.getParameterTypes(Method.java:174)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at java.lang.Class.getDeclaredMethods(Class.java:802)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at android.view.ViewDebug.getExportedPropertyMethods(ViewDebug.java:1118)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at android.view.ViewDebug.exportMethods(ViewDebug.java:1209)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:1155)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:1141)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at android.view.ViewDebug.dumpView(ViewDebug.java:1058)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:997)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:992)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:992)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:992)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:992)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:992)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:992)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:992)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:992)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:992)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at android.view.ViewDebug.dump(ViewDebug.java:855)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at android.ddm.DdmHandleViewDebug.dumpHierarchy(DdmHandleViewDebug.java:235)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at android.ddm.DdmHandleViewDebug.handleChunk(DdmHandleViewDebug.java:134)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at org.apache.harmony.dalvik.ddmc.DdmServer.dispatch(DdmServer.java:171)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.graphics.drawable.Icon" on path: DexPathList[[zip file "/data/app/com.tst.nikita.yandextranslater-2/base.apk", zip file "/data/app/com.tst.nikita.yandextranslater-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.tst.nikita.yandextranslater-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.tst.nikita.yandextranslater-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.tst.nikita.yandextranslater-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.tst.nikita.yandextranslater-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.tst.nikita.yandextranslater-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.tst.nikita.yandextranslater-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.tst.nikita.yandextranslater-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.tst.nikita.yandextranslater-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.tst.nikita.yandextranslater-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.tst.nikita.yandextranslater-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.tst.nikita.yandextranslater-2/lib/arm, /vendor/lib, /system/lib]]
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at libcore.reflect.InternalNames.getClass(InternalNames.java:53)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: ... 24 more
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: Suppressed: java.lang.ClassNotFoundException: android.graphics.drawable.Icon
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at java.lang.Class.classForName(Native Method)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
12-10 23:46:56.812 18833-18840/com.tst.nikita.yandextranslater W/System.err: at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
12-10 23:46:56.822 18833-18840/com.tst.nikita.yandextranslater W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
12-10 23:46:56.822 18833-18840/com.tst.nikita.yandextranslater W/System.err: ... 26 more
12-10 23:46:56.822 18833-18840/com.tst.nikita.yandextranslater W/System.err: Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
I use Android Studio 3.0.1.
Device - Samsung Galaxy S4 GT-I9505 with Android 5.0.1.
From manifest file:
compileSdkVersion 26
buildToolsVersion '26.0.3'
minSdkVersion 21
targetSdkVersion 26
I have noticed that this can also occur when using bluetooth. When i turned bluetooth off so that my code stopped scanning i could capture the View Hierarchy just fine.