I was doing some work with Android and wanted to test Retrolambda with it. But unfortunately I have encountered an issue.
I have an Dialog class that takes a Consumer as parameter:
public class AuthDialog extends Dialog {
public static final String SERVER_URL = "http://cohhgas.ddns.net/auth";
private Consumer<UserCredentials> onSuccess;
public AuthDialog(Context context, Consumer<UserCredentials> onSuccess) {
super(context);
this.onSuccess = onSuccess;
}
}
And I have an activity that uses it:
public class MainActivity extends AppCompatActivity {
public static final String CREDENTIALS = "sharedPrefsCredentials";
GiveAway giveAway;
SharedPreferences sharedpreferences;
public MainActivity() {
EventBus.getDefault().register(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final AuthDialog auth_dialog;
auth_dialog = new AuthDialog(MainActivity.this, userCredentials -> Log.d("cool", "works"));
auth_dialog.show();
TextView textView = new TextView(MainActivity.this);
textView.setOnClickListener((view) -> {
});
}
}
But the line initiating AuthDialog throws an exception at me! Here's the log:
Process: io.github.hajto.cohhcarnagegiveawayclient, PID: 3687
java.lang.NoClassDefFoundError: io.github.hajto.cohhcarnagegiveawayclient.activites.MainActivity$$Lambda$1
at io.github.hajto.cohhcarnagegiveawayclient.activites.MainActivity.onCreate(MainActivity.java:56)
at android.app.Activity.performCreate(Activity.java:6013)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2359)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2466)
at android.app.ActivityThread.access$1200(ActivityThread.java:152)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1341)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5538)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
What's the most interesting thing, if I remove that line, the onClick listener won't argue with next lambda.