0

I am new to android development. I am targeting API level 22 and with the following code, the app crashes:

Consumer<String> onError = new Consumer<String>(){
    public void accept(String t){
    }
}

I tried with a custom class implementing this interface and still the same behavior. Can someone explain it why.

Babu James
  • 2,740
  • 4
  • 33
  • 50

1 Answers1

0

Functional interfaces like java.util.Objects.Consumer from java8 cannot be accessed on devices targeted java7 or lower. According to documentation native support for functional interfaces is supported only from API 24

ConstOrVar
  • 2,025
  • 1
  • 11
  • 14