ClassNotFound: android.view.ViewStructure with Support Library 26.0.2 - 27.0.0
Asked Answered
P

2

8

I see a crash on Samsung Galaxy S5 with Android 4.4.2

NoClassDefFoundError: android/view/ViewStructure

This has been happening since I updated the Support Library to 26.0.2. Now it's also happening on 27.0.0, even though I expected such issues to have been resolved in it. I see a single crash in Crashlytics shortly after submitting the app to Google Play (I'm rolling out to a small percentage of my users). I don't know what the exact steps to reproduce are. So far I've assumed it's probably when the app is started.

Related reports:

java.lang.NoClassDefFoundError: android/graphics/drawable/Icon

ViewDebug.getExportedPropertyMethods java.lang.NoClassDefFound android/graphics/drawable/Icon

I am using Support library 27.0.0, compileSdkVersion 27, targetSdkVersion 25, buildToolsVersion '26.0.2', android plugin 2.3.3, gradle 3.3, Android Studio 3.0. (I'm guessing the issue is not related to the old versions of gradle and the plugin?...)

I can see ViewStructure is used in the support library in:

android.support.design.widget.TextInputLayout 
android.support.design.testutils.ViewStructureImpl

However, I am not using ViewStructure anywhere in my project.

Fatal Exception: java.lang.NoClassDefFoundError: android/view/ViewStructure
       at java.lang.Class.getDeclaredMethods(Class.java)
       at java.lang.Class.getDeclaredMethods(Class.java:656)
       at android.view.ViewDebug.getExportedPropertyMethods(ViewDebug.java:960)
       at android.view.ViewDebug.exportMethods(ViewDebug.java:1047)
       at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:997)
       at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:983)
       at android.view.ViewDebug.dumpView(ViewDebug.java:900)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:855)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dump(ViewDebug.java:793)
       at android.view.ViewDebug.dispatchCommand(ViewDebug.java:416)
       at android.view.ViewRootImpl$W.executeCommand(ViewRootImpl.java:6258)
       at android.view.IWindow$Stub.onTransact(IWindow.java:65)
       at android.os.Binder.execTransact(Binder.java:404)
       at dalvik.system.NativeStart.run(NativeStart.java)
Caused by java.lang.ClassNotFoundException: Didn't find class "android.view.ViewStructure" on path: DexPathList[[zip file "/data/app/package.name-1.apk"],nativeLibraryDirectories=[/data/app-lib/package.name-1, /vendor/lib, /system/lib]]
       at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
       at java.lang.Class.getDeclaredMethods(Class.java)
       at java.lang.Class.getDeclaredMethods(Class.java:656)
       at android.view.ViewDebug.getExportedPropertyMethods(ViewDebug.java:960)
       at android.view.ViewDebug.exportMethods(ViewDebug.java:1047)
       at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:997)
       at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:983)
       at android.view.ViewDebug.dumpView(ViewDebug.java:900)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:855)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dump(ViewDebug.java:793)
       at android.view.ViewDebug.dispatchCommand(ViewDebug.java:416)
       at android.view.ViewRootImpl$W.executeCommand(ViewRootImpl.java:6258)
       at android.view.IWindow$Stub.onTransact(IWindow.java:65)
       at android.os.Binder.execTransact(Binder.java:404)
       at dalvik.system.NativeStart.run(NativeStart.java)
Porphyrin answered 2/11, 2017 at 10:59 Comment(9)
What are you doing that is triggering the crash?Postiche
I edited the question with this info. I get a single crash in Crashlytics shortly after I roll out (to a small percentage of my user base) I don't know what the exact steps to reproduce are. So far I've assumed it's probably on app launch.Porphyrin
The stack traces look like it's the sort of thing that would come from utilities like Layout Inspector. ViewStructure was added in Android 6.0.Postiche
@Postiche I thought so, too. What crossed my mind was either a power user trying out weird stuff on my app, or Google doing an automated test/inspection, for some reason. Not sure. Soon I'll increase the rollout percentage and share if there's anything interesting.Porphyrin
My suspicions have been more or less confirmed here: issuetracker.google.com/issues/68796830 They will not fix it in the Support Library. "This should only occur if hierarchyviewer / ddm is connected." This is not a (regular) user crash.Porphyrin
Just happened to me as well. Just after closed alpha release same crash has been reported to crashlytics (just one so far). Same device: Samsung Galaxy S5 with Android 4.4.2. Will see how it goes after wider rollout. support_lib = '27.1.1' buildToolsVersion '27.0.3' target and compile - 27 gradle 4.4, plugin 3.1.1Dispenser
@fada21, have a same always after new build uploaded to Google Play dev console. I guess, it comes from Pre-launch test devices. Hope, we can just ignore it.Redeploy
@EugeneKrivenja yeah, it must be that, I've already closed that issue in crashlytics and ignoring, now it just serves as indicator that google processed the apk :pDispenser
@Porphyrin This is also a good way to see what data developers are uploading together with crash reports.Aloise
P
5

The most likely cause for this issue is that the user is not a regular user, because this "should only occur if hierarchyviewer / ddm is connected."

More info can be found here:

https://issuetracker.google.com/issues/68796830

Porphyrin answered 2/11, 2017 at 16:35 Comment(1)
What's odd about that is it implies that we can't use those tools with this version of the support library. But, glad to hear that you got an answer!Postiche
L
0

I'm in the process of migrating to Support lib 27.1.1 from 25.3.1 (yes people don't move so fast here...) and faced the same crash also when inflating TextInputLayouts.

After some investigation it turned out that we have a custom LayoutInflater which iterates through the full View Hierarchy and injects dependencies (using injectMembers(View)) in every View with Guice (maybe affects dagger as well). This is needed since we have custom Views which has dependencies injected through @Inject.

Since Guice iterates through the class and tries to access it's public methods when resolving dependencies, it runs into e.g TextInputLayout.dispatchProvideAutofillStructure(ViewStructure, int) which leads to a crash since ViewStructure isn't available on devices running < API 23.

So this is an example on what caused the problem for us, we don't have a good solution yet but probably we are either getting rid of injection inside custom views or we Annotate those views so that only these are injected when traversing the View tree.

Ld answered 9/5, 2018 at 11:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.