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

Fatal Exception: java.lang.NoSuchMethodError: No virtual method getAnnotationsByType #218

Closed
JeckChou opened this issue Mar 8, 2019 · 21 comments

Comments

@JeckChou
Copy link

JeckChou commented Mar 8, 2019

Fatal Exception: java.lang.NoSuchMethodError: No virtual method getAnnotationsByType(Ljava/lang/Class;)[Ljava/lang/annotation/Annotation; in class Ljava/lang/reflect/Field; or its super classes (declaration of 'java.lang.reflect.Field' appears in /system/framework/core-libart.jar)
       at com.fasterxml.jackson.module.kotlin.KotlinAnnotationIntrospector.hasRequiredMarker(KotlinAnnotationIntrospector.kt:45)
       at com.fasterxml.jackson.module.kotlin.KotlinAnnotationIntrospector.access$hasRequiredMarker(KotlinAnnotationIntrospector.kt:23)
       at com.fasterxml.jackson.module.kotlin.KotlinAnnotationIntrospector$hasRequiredMarker$1.invoke(KotlinAnnotationIntrospector.kt:32)
       at com.fasterxml.jackson.module.kotlin.KotlinAnnotationIntrospector$hasRequiredMarker$1.invoke(KotlinAnnotationIntrospector.kt:23)
       at com.fasterxml.jackson.module.kotlin.ReflectionCache.javaMemberIsRequired(KotlinModule.kt:92)
       at com.fasterxml.jackson.module.kotlin.KotlinAnnotationIntrospector.hasRequiredMarker(KotlinAnnotationIntrospector.kt:26)
       at com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair.hasRequiredMarker(AnnotationIntrospectorPair.java:307)
       at com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair.hasRequiredMarker(AnnotationIntrospectorPair.java:307)
       at com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder$4.withMember(POJOPropertyBuilder.java:655)
       at com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder$4.withMember(POJOPropertyBuilder.java:652)
       at com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder.fromMemberAnnotations(POJOPropertyBuilder.java:1154)
       at com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder._findRequired(POJOPropertyBuilder.java:652)
       at com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder.getMetadata(POJOPropertyBuilder.java:220)
       at com.fasterxml.jackson.databind.deser.SettableBeanProperty.<init>(SettableBeanProperty.java:137)
       at com.fasterxml.jackson.databind.deser.impl.FieldProperty.<init>(FieldProperty.java:46)
       at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.constructSettableProperty(BeanDeserializerFactory.java:803)
       at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.addBeanProps(BeanDeserializerFactory.java:520)
       at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:228)
       at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:137)
       at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:411)
       at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:349)
       at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:264)
       at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
       at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
       at com.fasterxml.jackson.databind.DeserializationContext.findNonContextualValueDeserializer(DeserializationContext.java:467)
       at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:473)
       at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:293)
       at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
       at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
       at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:477)
       at com.fasterxml.jackson.databind.ObjectReader._prefetchRootDeserializer(ObjectReader.java:1938)
       at com.fasterxml.jackson.databind.ObjectReader.<init>(ObjectReader.java:189)
       at com.fasterxml.jackson.databind.ObjectMapper._newReader(ObjectMapper.java:658)
       at com.fasterxml.jackson.databind.ObjectMapper.readerFor(ObjectMapper.java:3518)
       at com.garmin.android.apps.gccm.api.converter.JacksonConverterFactory.responseBodyConverter(JacksonConverterFactory.java:72)
       at retrofit2.Retrofit.nextResponseBodyConverter(Retrofit.java:328)
       at retrofit2.Retrofit.responseBodyConverter(Retrofit.java:311)
       at retrofit2.HttpServiceMethod.createResponseConverter(HttpServiceMethod.java:68)
       at retrofit2.HttpServiceMethod.parseAnnotations(HttpServiceMethod.java:46)
       at retrofit2.ServiceMethod.parseAnnotations(ServiceMethod.java:36)
       at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:168)
       at retrofit2.Retrofit$1.invoke(Retrofit.java:147)
       at java.lang.reflect.Proxy.invoke(Proxy.java:393)

version 2.9.8

I think this error is bron on version 2.9.7 , I have tested it on different android version and it is only crash below android 7.0 . it`s means that if android os version is 7.0+ this library is work good if not the error of above will shown.

@tonymanou
Copy link

tonymanou commented Mar 8, 2019

In order to make jackson-module-kotlin work on Android < API 24 you must stay on version 1.9.6 edit: 2.9.6, see #176

@matiasalvarez
Copy link

@tonymanou, did you mean 2.9.6? Version 1.9.6 does not exist but 2.9.6 worked for me.

@arlomedia
Copy link

I had the same problem and specifying version 2.9.6 worked for me, too.

@martinKindall
Copy link

@tonymanou Thanks, this worked for me.

@0megaD
Copy link

0megaD commented Aug 5, 2019

Just ran into this same issue. Are there any plans to support starting from API 21? Or is the module definitely going to stay at 24+?

@cowtowncoder
Copy link
Member

I don't know if we have anyone actively developing this module at this point. I can (and do) cut new releases as part of release process but can only make smallest changes as I do not use Kotlin myself.

Given this it might be useful to bring up the question of Kotlin module development on Jackson mailing list(s) to see if anyone could step up to help.

@apatrida
Copy link
Member

This is an issue with Android not supporting a JVM method to find annotations by type. I'm not sure when that was added to Java, but maybe can be replaced with similar handwritten function.

apatrida pushed a commit that referenced this issue Oct 29, 2019
@apatrida
Copy link
Member

Fixed on branch 2.10

@0megaD
Copy link

0megaD commented Oct 31, 2019

This doesn't seem to be fixed in 2.10.0 yet, but is supposed to be part of 2.10.1 or 2.11?

@apatrida
Copy link
Member

@0megaD it is fixed on the 2.10 branch, and pending a release. You can test it from the branch to help verify the problem is resolved. There might be snapshot builds available as well.

@starkej2
Copy link

Hi @apatrida - just wondering if you could point me to where I could find a snapshot build? And whether there is an ETA on the 2.10.1 release?

We are experiencing both the #167 and also #87, so kinda broken whether we switch to 2.9.6 or 2.10.0. Thanks!

@apatrida
Copy link
Member

likely on:

https://oss.sonatype.org/content/repositories/snapshots

        <repository>
            <id>snapshots-repo</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
            <releases><enabled>false</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
        </repository>

@apatrida
Copy link
Member

apatrida commented Oct 31, 2019

@starkej2 ^^

Also #167 was fixed a long time ago, is it not in a current release?
#87 is on the 2.10 branch and should be in a current snapshot if recent.

Should be snapshot release 2.10.1-SNAPSHOT

@starkej2
Copy link

Sorry I meant #130. Thanks again.

@apatrida
Copy link
Member

Great, seems like your issues were all tied up in this release then.

@starkej2
Copy link

How can I add that snapshot as a gradle dependency? Or am I supposed to download it somehow? I'm not familiar with how this works 😬

Tried adding this to my dependencies block, but it didn't work

maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.10.1-SNAPSHOT'

@apatrida
Copy link
Member

Yes, that looks correct. maybe this module isn't building to snapshots.

@cowtowncoder can you push a snapshot release?

@apatrida
Copy link
Member

Otherwise you can build to a local repo by pulling that branch and issuing a mvn clean install which would then make it available, from Gradle you would add the mavenLocal() repository.

Maybe @cowtowncoder can push a snapshot release instead.

@cowtowncoder
Copy link
Member

Was about to suggest local publish. Snapshots work bit better with Maven than Gradle, since they are Maven concept (gradle is pushing in bit different direction).

I can publish snapshot that from home tonight. Could try automating publishing via Travis, I think it works for databind. Just bit of a process to get credentials there lined up, repository by repository.

@cowtowncoder
Copy link
Member

Did push snapshot deploy last night, should be available. No auto-build still.

@starkej2
Copy link

starkej2 commented Nov 1, 2019

Awesome got it working, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants