Based on Use Java 8 language features method references are compatible with any minSdkVersion, then why Method reference requires API level 22?
Currently, I'm using Android Studio 3.2.1 with com.android.tools.build:gradle:3.2.1 and JDK 1.8, in build-gradle I have:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
Example
public class SimpleBundleEntry<V> extends BundleEntry<V> {
public SimpleBundleEntry(String key, V value,
BundleWriter<V> writer, BundleReader<V> reader)
{/*init*/}
// ...
public interface BundleReader<V> {
V readValue(Bundle bundle, String key);
}
public interface BundleWriter<V> {
void writeValue(Bundle bundle, String key, V value);
}
}
Problematic code
public static BundleEntry<Boolean> ofBoolean(String key, Boolean value) {
return new SimpleBundleEntry<>(key, value,
Bundle::putBoolean, // <------------------- PROBLEM HERE
(bundle, k) -> bundle.getBoolean(k));
}