NFC use -source 8 or higher to enable lambda expressions

#1

hi everyone,

i’m using NFC plugin
$ ionic cordova plugin add phonegap-nfc
$ npm install --save @ionic-native/nfc

but when im build for android, show this error:

:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
C:\xampp\htdocs\projectsMovil\NFC\platforms\android\src\com\chariotsolutions\nfc\plugin\NfcPlugin.java:80: error: diamond operator is not supported in -source 1.6
private final List intentFilters = new ArrayList<>();
^
(use -source 7 or higher to enable diamond operator)
C:\xampp\htdocs\projectsMovil\NFC\platforms\android\src\com\chariotsolutions\nfc\plugin\NfcPlugin.java:214: error: lambda expressions are not supported in -source 1.6
getActivity().runOnUiThread(() -> {
^
(use -source 8 or higher to enable lambda expressions)
2 errors
:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong:

BUILD FAILED

Total time: 3.025 secs

Execution failed for task ‘:compileDebugJavaWithJavac’.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    Error: cmd: Command failed with exit code 1 Error output:
    C:\xampp\htdocs\projectsMovil\NFC\platforms\android\src\com\chariotsolutions\nfc\plugin\NfcPlugin.java:80: error: diamond operator is not supported in -source 1.6
    private final List intentFilters = new ArrayList<>();
    ^
    (use -source 7 or higher to enable diamond operator)
    C:\xampp\htdocs\projectsMovil\NFC\platforms\android\src\com\chariotsolutions\nfc\plugin\NfcPlugin.java:214: error: lambda expressions are not supported in -source 1.6
    getActivity().runOnUiThread(() -> {
    ^
    (use -source 8 or higher to enable lambda expressions)
    2 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:compileDebugJavaWithJavac’.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

[ERROR] An error occurred while running cordova build android (exit code 1).

Any solution ? Thanks

#2

What is your JDK version?

#3

this is my version : jdk1.8.0_171

#4

Looks relevant.

#5

i’m change in gradle

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

and add
jackOptions {
enabled true
}
in defaultConfig

new error

:transformClassesWithPreJackPackagedLibrariesForDebug
FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:transformClassesWithPreJackPackagedLibrariesForDebug’.

java.lang.NullPointerException (no error message)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 6.022 secs
Error: cmd: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:transformClassesWithPreJackPackagedLibrariesForDebug’.

java.lang.NullPointerException (no error message)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

[ERROR] An error occurred while running cordova run android (exit code 1).

#6

this is before, i believe that It’s part of the mistake

Incremental java compilation is an incubating feature.

cordova build android
ANDROID_HOME=C:\Users\Usuario\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_171
Subproject Path: CordovaLib
[19:00:48] lint finished in 2.32 s
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.

    at build_4n6fh8zy8pzn566rku0lkq9jy.run(C:\xampp\htdocs\projectsMovil\NFC\platforms\android\build.gradle:137)

The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.

Incremental java compilation is an incubating feature.

The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead.

:preBuild
UP-TO-DATE
:preDebugBuild UP-TO-DATE
:compileDebugNdk UP-TO-DATE
:checkDebugManifest
… etc

#7

I am having same error as mentioned above, can anyone found the solution.

Help would be appreciated.
Thanks