How use lambda expressions in android? For example, I compile this code in IntelliJ IDEA:
package com.example.myapp;
import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
public class MyActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
test s = () -> {return "Lambda expressions test";};
AlertDialog alertDialog = new AlertDialog.Builder(this)
.setTitle("Lambda expression")
.setMessage(s.t())
.create();
alertDialog.show();
}
}
interface test {
public String t();
}
But have this erorrs:
Information:Using javac 1.8.0_05 to compile java sources
Information:36 errors
Information:0 warnings
Information:Compilation completed with 36 errors and 0 warnings in 29 sec
Error:Android Dex: [myappі] UNEXPECTED TOP-LEVEL EXCEPTION:
Error:Android Dex: [myappі] com.android.dx.cf.iface.ParseException: InvokeDynamic not supported
How to set up so you can use lambda expressions?