Skip to content

Android: gradle configuration of object-diff : crash when run application  #147

Closed

Description

@svakulenko

Hi

i try to use this library, let looks what we have :

build.gradle :
...
compile 'org.slf4j:slf4j-api:1.7.12'
compile 'eu.lp0.slf4j:slf4j-android:1.7.12-0'
compile 'de.danielbechler:java-object-diff:0.93'

logcat crash :

12-09 14:44:51.278 E/AndroidRuntime(15723): java.lang.NoClassDefFoundError: Failed resolution of: Ljava/beans/Introspector;
12-09 14:44:51.278 E/AndroidRuntime(15723): at de.danielbechler.diff.introspection.StandardIntrospector.getBeanInfo(StandardIntrospector.java:71)
12-09 14:44:51.278 E/AndroidRuntime(15723): at de.danielbechler.diff.introspection.StandardIntrospector.internalIntrospect(StandardIntrospector.java:53)
12-09 14:44:51.278 E/AndroidRuntime(15723): at de.danielbechler.diff.introspection.StandardIntrospector.introspect(StandardIntrospector.java:42)
12-09 14:44:51.278 E/AndroidRuntime(15723): at de.danielbechler.diff.introspection.IntrospectionService.typeInfoForNode(IntrospectionService.java:90)
12-09 14:44:51.278 E/AndroidRuntime(15723): at de.danielbechler.diff.differ.BeanDiffer.compareUsingIntrospection(BeanDiffer.java:110)
12-09 14:44:51.278 E/AndroidRuntime(15723): at de.danielbechler.diff.differ.BeanDiffer.compareUsingAppropriateMethod(BeanDiffer.java:104)
12-09 14:44:51.278 E/AndroidRuntime(15723): at de.danielbechler.diff.differ.BeanDiffer.compare(BeanDiffer.java:85)
12-09 14:44:51.278 E/AndroidRuntime(15723): at de.danielbechler.diff.differ.DifferDispatcher.compare(DifferDispatcher.java:188)
12-09 14:44:51.278 E/AndroidRuntime(15723): at de.danielbechler.diff.differ.DifferDispatcher.compareWithCircularReferenceTracking(DifferDispatcher.java:158)
12-09 14:44:51.278 E/AndroidRuntime(15723): at de.danielbechler.diff.differ.DifferDispatcher.compare(DifferDispatcher.java:145)
12-09 14:44:51.278 E/AndroidRuntime(15723): at de.danielbechler.diff.differ.DifferDispatcher.dispatch(DifferDispatcher.java:93)
12-09 14:44:51.278 E/AndroidRuntime(15723): at de.danielbechler.diff.ObjectDiffer.compare(ObjectDiffer.java:49)

Could you can give me a tip how to make it work ?

Thanks

Activity

  1. SQiShER commented on Dec 9, 2015

    @SQiShER
    Owner

    Per default java-object-diff uses the java.beans.Introspector to resolve properties and their corresponding getters and setters from the types its trying to compare. It looks like the AndroidRuntime doesn't come with this class. That's something I wasn't aware of. The only way around that would be to implement a custom introspector, which doesn't rely on the java.beans class and either uses something similar from the AndroidRuntime or just plain old reflection.

    The StandardIntrospector would be a good starting point. Basically all you'd have to do would be to implement the method TypeInfo introspect(Class<?> type) and populate the TypeInfo with information about the available properties of the given type.

    The resulting Introspector can then be configured via ObjectDifferBuilder.

    Come to think of it, now that I know that Android doesn't ship with java.beans.Introspector, I think it makes sense to change the default to use regular reflection and perhaps offer alternative implementations for people who rely on the performance advantages of the more advanced introspector. But for now, I'm afraid you have to build your own solution. 😞

  2. changed the title [-]gradle configuration of object-diff : crash when run application [/-] [+]Android: gradle configuration of object-diff : crash when run application [/+] on Dec 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions