Q:

Error java.lang.NoClassDefFoundError: com.github.difflib.text.DiffRowGenerator$$Lambda$0

Inside my Android project I'm using java-diff-utils.
I've added it to dependency this way:
implementation group: 'com.github.wumpz', name: 'diffutils', version: '2.2'

Also tried change it to this:
implementation 'io.github.java-diff-utils:java-diff-utils:4.0-SNAPSHOT'

I have two test devices: a tablet with Android 6.0.1 and a phone with Android 8.1.0.
When I'm running this project on phone, everything goes fine. But on tablet, as soon as a hit the java-diff-utils code, app crashes with error
    java.lang.NoClassDefFoundError: com.github.difflib.text.DiffRowGenerator$$Lambda$0
    at com.github.difflib.text.DiffRowGenerator.<clinit>(DiffRowGenerator.java:52)
    at com.github.difflib.text.DiffRowGenerator.create(DiffRowGenerator.java:210)
    at Fragments.ProfileFragment.onCreateView(ProfileFragment.java:38)
    at android.app.Fragment.performCreateView(Fragment.java:2220)
    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973)
    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
    at android.app.BackStackRecord.run(BackStackRecord.java:793)
    at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535)
    at android.app.FragmentManagerImpl$1.run(FragmentManager.java:482)
    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:5461)
    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)

The same issue happened, when I was using Sugar ORM. 
My build.gradle config:
android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "someid"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}

Why this is happening and is there any way I can solve it?

A:

There is usage of java.util.function.BiPredicate in DiffRowGenerator.java:52 of library you using (that is where crash happen due to stacktrace). Link to source. Whole package java.util.function.* can be used only starting API 24 (Android 7.0). Thats why it's working on Android 8 and not working on Android 6. More about java 8 compatibility with android you can read in official documentation: https://developer.android.com/studio/write/java8-support
If you have to use that library you have options:

Do not support Android below 7.0.
Use older library version. As I can see that library started using Java 8 features since version 2.0. So you can try version 1.2 of that library.
Fork library and rewrite all places where unsupported Java 8 functionality is used.

