Android Compiling Error - Failed to find byte code for java/util/function/Function

It seems that there are several reasons causing this problem.

If you use Kotlin, try changing forEach{ key, value -> ... } to forEach{ (key, value) -> ... }

In my situation, I never use Kotlin. After disable Instant Run, this error gone.


I found the solution for my problem here: Why does Kotlin byte code reference java.util.function.BiConsumer?

I am using Kotlin and I found the line that uses forEach{ key, value -> ... }, and changed it to forEach{ (key, value) -> ... }, which makes Kotlin choose JRE 6 instead of 8.


This looks like a compiler issue. Did you try restarting your Android studio? If yes, then try

Build-> Clean Project
Build-> Make Project

If the issue still persists, try to clear cache by File > Invalidate Caches & Restart...

If everything fails, try disabling Instant Run.