Results 1 to 5 of 5

Thread: QT Creator 4.12.4 and Java Lambda issue

  1. #1
    Join Date
    Dec 2019
    Posts
    13
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default 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:
    1. > Task :compileDebugJavaWithJavac FAILED
    2. E:\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
    3. rtsBtn.setOnClickListener(this::toggle);
    4. ^
    5. (use -source 8 or higher to enable method references)
    6. 1 error
    7.  
    8. FAILURE: Build failed with an exception.
    9.  
    10. * What went wrong:
    11. Execution failed for task ':compileDebugJavaWithJavac'.
    12. > Compilation failed; see the compiler error output for details.
    13.  
    14. * Try:
    15. 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.
    16.  
    17. * 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 17:27.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default 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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Dec 2019
    Posts
    13
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QT Creator 4.12.4 and Java Lambda issue

    Quote Originally Posted by d_stranz View Post
    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.
    Ok ,i saw it already.
    I searched this word everywhere, google youtube etc. where should i define?

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QT Creator 4.12.4 and Java Lambda issue

    Maybe this link will help.

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    Dec 2019
    Posts
    13
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default 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
    }
    ....
    }

Similar Threads

  1. Why is the lambda crashing my program?
    By ayanda83 in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2017, 10:13
  2. QTimer Lambda
    By bmn in forum Qt Programming
    Replies: 2
    Last Post: 8th March 2016, 08:23
  3. How do I add Java code to Qt Android apps via Qt Creator
    By scottwild in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 2nd October 2013, 00:09
  4. Lambda callback functions
    By wayfaerer in forum Newbie
    Replies: 3
    Last Post: 12th March 2012, 11:33
  5. [java] HasSet vs ArrayList and modelling issue
    By mickey in forum General Programming
    Replies: 2
    Last Post: 13th September 2010, 19:14

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.