# Thread: QT Creator 4.12.4 and Java Lambda issue

1. Beginner
Join Date
Dec 2019
Posts
12
Thanks
2
Qt products
Platforms

## QT Creator 4.12.4 and Java Lambda issue

I already have android studio installed on my computer

B6ZlBkQVmw.png

And its configure JDK , Android Sdk

studio64_VXLEkKtHfS.jpg

so far so good. if I set same variable to QT creator

qtcreator_k2Utkgn4R6.png

qtcreator_46IbeDx5u3.jpg

when i run my project, there is no problem. so far so good

but whenever I add a lambda expression to my java file, I get an error.

qtcreator_90X7mIEVOY.jpg

Qt Code:
`> Task :compileDebugJavaWithJavac FAILEDE:\kutuphane\belgelerim\QT Projects\JniTest2\android-build\src\org\qtproject\example\JniTest2\TerminalFragment.java:336: error: method references are not supported in -source 1.7            rtsBtn.setOnClickListener(this::toggle);                                            ^  (use -source 8 or higher to enable method references)1 error 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. Run with --scan to get full insights. * Get more help at https://help.gradle.org`
To copy to clipboard, switch view to plain text mode

however, the project with the same lambda works in android studio. qt and A.studio have same jdk . and insist that the qt jdk version is less than 8 ???
how can this be. where am i making a mistake.

>
>
>
Last edited by sevketk; 24th July 2020 at 16:27.

2. ## Re: QT Creator 4.12.4 and Java Lambda issue

(use -source 8 or higher to enable method references)
Seems to me this is telling you exactly what to do to fix the problem. There is a preprocessor definition in Android Studio's compile options that isn't defined in Qt Creator's options, so you need to add it.

3. Beginner
Join Date
Dec 2019
Posts
12
Thanks
2
Qt products
Platforms

## Re: QT Creator 4.12.4 and Java Lambda issue

Originally Posted by d_stranz
Seems to me this is telling you exactly what to do to fix the problem. There is a preprocessor definition in Android Studio's compile options that isn't defined in Qt Creator's options, so you need to add it.
I searched this word everywhere, google youtube etc. where should i define?

4. ## Re: QT Creator 4.12.4 and Java Lambda issue

It appears to be a command line option to the javac compiler. Look at how Android Studio calls the javac compiler, and copy the same to Qt Creator's javac command line. I don't know exactly how you do this; I have never configured a kit to use javac.

5. Beginner
Join Date
Dec 2019
Posts
12
Thanks
2
Qt products
Platforms

## Re: QT Creator 4.12.4 and Java Lambda issue

I found the solution to the problem. Let me write it here and benefit other friends. all you have to do is insert these two lines into the build.gradle file, inside the android fancy brackets. that's all.

android {
.....
.....
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
....
}