Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing support-compat Dependency #505

Closed
commonsguy opened this issue Mar 2, 2017 · 3 comments
Closed

Missing support-compat Dependency #505

commonsguy opened this issue Mar 2, 2017 · 3 comments
Assignees
Labels

Comments

@commonsguy
Copy link

Stetho needs android.support.v4.view.accessibility.AccessibilityNodeInfoCompat. However, it does not depend upon support-compat, the Android SDK artifact that (now) houses that class. As a result, if the project does not already have that dependency, Stetho crashes.

The attached project can be used to reproduce the problem. At the moment, support-compat is commented out in app/build.gradle. If you run the project, and you start navigating the view hierarchy using the Elements view, after a few layers, you eventually crash with:

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/view/accessibility/AccessibilityNodeInfoCompat;
      at com.facebook.stetho.inspector.elements.android.ViewDescriptor.onGetAccessibilityStyles(ViewDescriptor.java:189)
      at com.facebook.stetho.inspector.elements.android.ViewDescriptor.onGetAccessibilityStyles(ViewDescriptor.java:40)
      at com.facebook.stetho.inspector.elements.AbstractChainedDescriptor.getAccessibilityStyles(AbstractChainedDescriptor.java:163)
      at com.facebook.stetho.inspector.elements.AbstractChainedDescriptor.getAccessibilityStyles(AbstractChainedDescriptor.java:162)
      at com.facebook.stetho.inspector.elements.Document.getElementAccessibilityStyles(Document.java:153)
      at com.facebook.stetho.inspector.protocol.module.CSS$2.run(CSS.java:150)
      at com.facebook.stetho.common.android.HandlerUtil$2.onRun(HandlerUtil.java:90)
      at com.facebook.stetho.common.android.HandlerUtil$2.onRun(HandlerUtil.java:87)
      at com.facebook.stetho.common.android.HandlerUtil$WaitableRunnable.run(HandlerUtil.java:109)
      at android.os.Handler.handleCallback(Handler.java:739)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:148)
      at android.app.ActivityThread.main(ActivityThread.java:5417)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.view.accessibility.AccessibilityNodeInfoCompat" on path: DexPathList[[zip file "/data/app/com.commonsware.android.stetho-1/base.apk"],nativeLibraryDirectories=[/data/app/com.commonsware.android.stetho-1/lib/arm, /vendor/lib, /system/lib]]
      at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
      at com.facebook.stetho.inspector.elements.android.ViewDescriptor.onGetAccessibilityStyles(ViewDescriptor.java:189) 
      at com.facebook.stetho.inspector.elements.android.ViewDescriptor.onGetAccessibilityStyles(ViewDescriptor.java:40) 
      at com.facebook.stetho.inspector.elements.AbstractChainedDescriptor.getAccessibilityStyles(AbstractChainedDescriptor.java:163) 
      at com.facebook.stetho.inspector.elements.AbstractChainedDescriptor.getAccessibilityStyles(AbstractChainedDescriptor.java:162) 
      at com.facebook.stetho.inspector.elements.Document.getElementAccessibilityStyles(Document.java:153) 
      at com.facebook.stetho.inspector.protocol.module.CSS$2.run(CSS.java:150) 
      at com.facebook.stetho.common.android.HandlerUtil$2.onRun(HandlerUtil.java:90) 
      at com.facebook.stetho.common.android.HandlerUtil$2.onRun(HandlerUtil.java:87) 
      at com.facebook.stetho.common.android.HandlerUtil$WaitableRunnable.run(HandlerUtil.java:109) 
      at android.os.Handler.handleCallback(Handler.java:739) 
      at android.os.Handler.dispatchMessage(Handler.java:95) 
      at android.os.Looper.loop(Looper.java:148) 
      at android.app.ActivityThread.main(ActivityThread.java:5417) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Suppressed: java.lang.ClassNotFoundException: android.support.v4.view.accessibility.AccessibilityNodeInfoCompat
      at java.lang.Class.classForName(Native Method)
      at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
      at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
          ... 17 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

If you uncomment the debugCompile 'com.android.support:support-compat:25.2.0' statement in Gradle, Stetho runs without issue.

Let me know if you need additional information — thanks!

Stetho.zip

@jasta
Copy link
Contributor

jasta commented Mar 3, 2017

Hmm I think this was actually a mistake in the accessibility diffs. We should not have a hard dependency on the compat library for accessibility but rather should be using the compat lib only if it's present and also using the framework version directly if it's available (we're running on the right platform version)

@jasta
Copy link
Contributor

jasta commented Mar 3, 2017

Looking at this closer, this was definitely a mistake. We're using support lib and compat library code without checking whether it's in the classpath which means that we now have an undeclared hard dependency on two libraries we explicitly didn't want to hard dep. I'm somewhat surprised we're not seeing more users complaining about this actually...

@jasta jasta added the bug label Mar 3, 2017
@blavalla
Copy link
Contributor

#511 should resolve this issue. If you don't include the support library in your application it will simply disable the accessibility inspection feature.

@jasta jasta closed this as completed Apr 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants