question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Didn't find class "java.lang.invoke.MethodHandles$Lookup"

See original GitHub issue

//retrofit

  implementation 'com.squareup.retrofit2:converter-moshi:2.8.0'
  implementation 'com.squareup.retrofit2:retrofit:2.8.0'
  implementation 'com.squareup.retrofit2:adapter-rxjava2:2.8.0'
  implementation 'com.squareup.retrofit2:converter-gson:2.8.0'

It doesn’t work with either moshi either gson converters.

Gradle configured with

compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }

kotlinOptions {
        jvmTarget = "1.8"
    }

Also tried

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

What’s the error?

Caused by: java.lang.ClassNotFoundException: Didn’t find class “java.lang.invoke.MethodHandles$Lookup”

It happens only on: Android 7.0 Android 7.1.1 Android 7.1.2

Where does it print the stack trace?

https://github.com/square/retrofit/blob/master/retrofit/src/main/java/retrofit2/Platform.java Line 62, 115, 44, 34, 37, 430

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:8

github_iconTop GitHub Comments

1reaction
ashley-figueiracommented, May 24, 2020

What is the fix for this? I’ve upgraded to Retrofit 2.9.0 and im still getting this crash for Android 7.X … Using Java 1.8 and gradle plugin 3.6.1

0reactions
FunkyMusecommented, May 24, 2020

What is the fix for this? I’ve upgraded to Retrofit 2.9.0 and im still getting this crash for Android 7.X … Using Java 1.8 and gradle plugin 3.6.1

Did you update your retrofit adapters too?

I did.

I just tested it on Android 7.1.1

def retrofit = "2.9.0"
   implementation "com.squareup.retrofit2:converter-moshi:$retrofit"
    implementation "com.squareup.retrofit2:retrofit:$retrofit"
    implementation "com.squareup.retrofit2:adapter-rxjava3:$retrofit"
    implementation "com.squareup.retrofit2:converter-gson:$retrofit"
    implementation 'com.squareup.okhttp3:logging-interceptor:4.7.2'

I didn’t get any crash not with gson or rxjava3 adapter or moshi in this case

Try to clean your project and re-build? Invalidate caches and restart?

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.lang.NoClassDefFoundError: Failed resolution of: Ljava ...
try changing minsdk to 26. as MethodHandles$Lookup class was added in API level 26. refer this docs. This means you can't install your...
Read more >
MethodHandles$Lookup.findSpecial - Java - Tabnine
Best Java code snippets using java.lang.invoke.MethodHandles$Lookup.findSpecial (Showing top 20 results out of 315) ; MethodType methodType = MethodType.
Read more >
MethodHandles.Lookup (Java SE 9 & JDK 9 )
invoke performs access checking against every caller, on every call. All access checks start from a Lookup object, which compares its recorded lookup...
Read more >
Diff - platform/libcore - Google Git
findClass (name, suppressedExceptions); if (c == null) { - ClassNotFoundException ... diff --git a/ojluni/src/main/java/java/lang/invoke/MethodHandle.java ...
Read more >
App crashes when java.date.LocalDate is being passed as ...
at androidx.navigation.NavType.fromArgType(NavType.java:169) ... 38 more. Caused by: java.lang.ClassNotFoundException: Didn't find class "java.time.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found