Home > Blockchain >  Java - fix lambda expression either with version or conversion
Java - fix lambda expression either with version or conversion

Time:09-22

I am trying to add a custom capacitor plugin to my android app. Works for iOS, currently I am integrating it into android.

I am no Java developer, my Java knowledge is fairly old. The build step of the app that builds the plugin alongside throws

        request.addOnCompleteListener(task -> {
                                           ^
  (use -source 8 or higher to enable lambda expressions)
  1. Where can I amp up my Java version to 8 in my ionic project to build with lambdas?
  2. How could I make this compatible with -source 7 ?
        Activity activity = this.cordova.getActivity();
        ReviewManager manager = ReviewManagerFactory.create(activity);
        Task<ReviewInfo> request = manager.requestReviewFlow();


        request.addOnCompleteListener(task -> {

            if (task.isSuccessful()) {
                ReviewInfo reviewInfo = task.getResult();
                Task<Void> flow = manager.launchReviewFlow(activity, reviewInfo);
                flow.addOnCompleteListener(launchTask -> {
                    if (task.isSuccessful()) {
                        callbackContext.success();
                    } else {
                        Exception error = task.getException();
                        callbackContext.error("Failed to launch review - "   error.getMessage());
                    }
                });
            } else {
                Exception error = task.getException();
                callbackContext.error("Failed to launch review flow - "   error.getMessage());
            }

        });

The code is based on https://developer.android.com/guide/playcore/in-app-review/kotlin-java#java

CodePudding user response:

You need to set the Java version for the project.

It's in build.gradle

https://developer.android.com/studio/write/java8-support

  • Related