Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. use Java code in Qt prolem of compilation
Forum Updated to NodeBB v4.3 + New Features

use Java code in Qt prolem of compilation

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
19 Posts 2 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    Based on the error message, are you using an unusual charset somewhere ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • E Offline
      E Offline
      ENSAO_CHEIKH
      wrote on last edited by
      #5

      I don't change anything I follow projects>> Android APK>> create template, then a java directories are created, so I attempt to create a java class to do a simple tak, I've otten this problem

      1 Reply Last reply
      0
      • E Offline
        E Offline
        ENSAO_CHEIKH
        wrote on last edited by
        #6

        Mr @SGaist here is below my simple code
        4a8437b3-29ef-4b46-adae-6f2daf0e259a-image.png

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #7

          Can you provide the full error ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • E Offline
            E Offline
            ENSAO_CHEIKH
            wrote on last edited by
            #8

            here is the full error shown in the image below:

            7761063d-a9cb-44ea-9e8f-c66c5bdfe9df-image.png

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #9

              Did you check your file encoding ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              E 2 Replies Last reply
              0
              • E Offline
                E Offline
                ENSAO_CHEIKH
                wrote on last edited by
                #10

                which file? gradlew.bat file??

                1 Reply Last reply
                0
                • SGaistS SGaist

                  Did you check your file encoding ?

                  E Offline
                  E Offline
                  ENSAO_CHEIKH
                  wrote on last edited by
                  #11

                  @SGaist

                  @if "%DEBUG%" == "" @echo off
                  @rem ##########################################################################
                  @rem
                  @rem  Gradle startup script for Windows
                  @rem
                  @rem ##########################################################################
                  
                  @rem Set local scope for the variables with windows NT shell
                  
                  if "%OS%"=="Windows_NT" setlocal
                  
                  set DIRNAME=%~dp0
                  if "%DIRNAME%" == "" set DIRNAME=.
                  set APP_BASE_NAME=%~n0
                  set APP_HOME=%DIRNAME%
                  
                  
                  @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
                  set DEFAULT_JVM_OPTS=
                  
                  @rem Find java.exe
                  if defined JAVA_HOME goto findJavaFromJavaHome
                  
                  set JAVA_EXE=java.exe
                  %JAVA_EXE% -version >NUL 2>&1
                  if "%ERRORLEVEL%" == "0" goto init
                  
                  echo.
                  echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
                  echo.
                  echo Please set the JAVA_HOME variable in your environment to match the
                  echo location of your Java installation.
                  
                  goto fail
                  
                  :findJavaFromJavaHome
                  set JAVA_HOME=%JAVA_HOME:"=%
                  set JAVA_EXE=%JAVA_HOME%/bin/java.exe
                  
                  if exist "%JAVA_EXE%" goto init
                  
                  echo.
                  echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
                  echo.
                  echo Please set the JAVA_HOME variable in your environment to match the
                  echo location of your Java installation.
                  
                  goto fail
                  
                  :init
                  @rem Get command-line arguments, handling Windows variants
                  
                  if not "%OS%" == "Windows_NT" goto win9xME_args
                  
                  :win9xME_args
                  @rem Slurp the command line arguments.
                  set CMD_LINE_ARGS=
                  set _SKIP=2
                  
                  :win9xME_args_slurp
                  if "x%~1" == "x" goto execute
                  
                  set CMD_LINE_ARGS=%*
                  
                  :execute
                  @rem Setup the command line
                  
                  set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
                  
                  @rem Execute Gradle
                  "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
                  
                  :end
                  @rem End local scope for the variables with windows NT shell
                  if "%ERRORLEVEL%"=="0" goto mainEnd
                  
                  :fail
                  rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
                  rem the _cmd.exe /c_ return code!
                  if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
                  exit /b 1
                  
                  :mainEnd
                  if "%OS%"=="Windows_NT" endlocal
                  
                  :omega
                  
                  
                  1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Did you check your file encoding ?

                    E Offline
                    E Offline
                    ENSAO_CHEIKH
                    wrote on last edited by
                    #12

                    Mr @SGaist please any idea? this problem persist one week, i am still blocked with my app

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #13

                      I'd start with a default project and ensure that it builds and run properly, then add the Java parts from scratch using new files.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • E Offline
                        E Offline
                        ENSAO_CHEIKH
                        wrote on last edited by
                        #14

                        Here you could find my file .pro

                        QT += quick
                        QT += quickcontrols2
                        QT += network
                        QT += bluetooth
                        QT += core
                        QT += androidextras
                        
                        
                        
                        CONFIG += c++11
                        
                        # The following define makes your compiler emit warnings if you use
                        # any Qt feature that has been marked deprecated (the exact warnings
                        # depend on your compiler). Refer to the documentation for the
                        # deprecated API to know how to port your code away from it.
                        DEFINES += QT_DEPRECATED_WARNINGS
                        
                        # You can also make your code fail to compile if it uses deprecated APIs.
                        # In order to do so, uncomment the following line.
                        # You can also select to disable deprecated APIs only up to a certain version of Qt.
                        #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
                        
                        
                        
                        
                        SOURCES += \
                                bluetooth.cpp \
                                main.cpp \
                                wificonnection.cpp
                        
                        RESOURCES += qml.qrc
                        
                        # Additional import path used to resolve QML modules in Qt Creator's code model
                        QML_IMPORT_PATH =
                        
                        # Additional import path used to resolve QML modules just for Qt Quick Designer
                        QML_DESIGNER_IMPORT_PATH =
                        
                        
                        
                        
                        
                        
                        
                        # Default rules for deployment.
                        qnx: target.path = /tmp/$${TARGET}/bin
                        else: unix:!android: target.path = /opt/$${TARGET}/bin
                        !isEmpty(target.path): INSTALLS += target
                        
                        HEADERS += \
                            bluetooth.h \
                            wificonnection.h
                        
                        DISTFILES += \
                            android/AndroidManifest.xml \
                            android/build.gradle \
                            android/gradle/wrapper/gradle-wrapper.jar \
                            android/gradle/wrapper/gradle-wrapper.properties \
                            android/gradlew \
                            android/gradlew.bat \
                            android/res/values/libs.xml \
                            android/src/org/JavaClass/JavaClass.java
                        
                        ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
                        
                        
                        
                        
                        
                        1 Reply Last reply
                        0
                        • E Offline
                          E Offline
                          ENSAO_CHEIKH
                          wrote on last edited by
                          #15

                          here is all the issue :

                          Warning: QML import could not be resolved in any of the import paths: QtQuick.Extras.Private.CppUtils
                          Warning: QML import could not be resolved in any of the import paths: QtQuick.Extras.Private.CppUtils
                          Starting a Gradle Daemon, 2 incompatible Daemons could not be reused, use --status for details
                          
                          FAILURE: Build failed with an exception.
                          
                          * What went wrong:
                          Unable to start the daemon process.
                          This problem might be caused by incorrect configuration of the daemon.
                          For example, an unrecognized jvm option is used.
                          Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/5.6.4/userguide/gradle_daemon.html
                          Process command line: C:\Program Files\Java\jdk1.8.0_271\bin\java.exe -Xmx2048m -Dfile.encoding -Duser.country=FR -Duser.language=fr -Duser.variant -cp C:\Users\achraf\.gradle\wrapper\dists\gradle-5.6.4-bin\bxirm19lnfz6nurbatndyydux\gradle-5.6.4\lib\gradle-launcher-5.6.4.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 5.6.4
                          Please read the following process output to find out more:
                          -----------------------
                          Error occurred during initialization of VM
                          java.nio.charset.IllegalCharsetNameException: 
                          	at java.nio.charset.Charset.checkName(Charset.java:303)
                          	at java.nio.charset.Charset.lookup2(Charset.java:484)
                          	at java.nio.charset.Charset.lookup(Charset.java:464)
                          	at java.nio.charset.Charset.defaultCharset(Charset.java:609)
                          	at sun.nio.cs.StreamEncoder.forOutputStreamWriter(StreamEncoder.java:56)
                          	at java.io.OutputStreamWriter.<init>(OutputStreamWriter.java:111)
                          	at java.io.PrintStream.<init>(PrintStream.java:104)
                          	at java.io.PrintStream.<init>(PrintStream.java:151)
                          	at java.lang.System.newPrintStream(System.java:1148)
                          	at java.lang.System.initializeSystemClass(System.java:1192)
                          
                          
                          * 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
                          Building the android package failed!
                            -- For more information, run this command with --verbose.
                          12:42:30: Le processus "D:\Qt\5.15.2\android\bin\androiddeployqt.exe" s'est terminé avec le code 14.
                          Erreur lors de la compilation/déploiement du projet untitled2 (kit : Android for armeabi-v7a,arm64-v8a,x86,x86_64 (Clang Qt 5.15.2 for Android))
                          When executing step "Build Android APK"
                          12:42:30: Elapsed time: 00:23.
                          
                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #16

                            Looks wrong:
                            @ENSAO_CHEIKH said in use Java code in Qt prolem of compilation:

                            -Dfile.encoding

                            there should be a value there.

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            E 2 Replies Last reply
                            0
                            • SGaistS SGaist

                              Looks wrong:
                              @ENSAO_CHEIKH said in use Java code in Qt prolem of compilation:

                              -Dfile.encoding

                              there should be a value there.

                              E Offline
                              E Offline
                              ENSAO_CHEIKH
                              wrote on last edited by
                              #17

                              @SGaist pkease in which file I find this -Dfile.encoding, I dont see it ?

                              1 Reply Last reply
                              0
                              • SGaistS SGaist

                                Looks wrong:
                                @ENSAO_CHEIKH said in use Java code in Qt prolem of compilation:

                                -Dfile.encoding

                                there should be a value there.

                                E Offline
                                E Offline
                                ENSAO_CHEIKH
                                wrote on last edited by
                                #18

                                @SGaist please where can I put this -Dfile encoding?

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #19

                                  Please show some patience and allow at least 24 hours to pass before bumping your own thread. This is a voluntary driven forum and people may not live in the same time zone as you.

                                  I currently do not have a Windows machine at hand to check your issue.

                                  That said:

                                  • did you try to apply my suggestion to start from a default project and once it's built, add the Java part ?
                                  • did you check your gradle related files for encoding entries ?

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  0

                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • Users
                                  • Groups
                                  • Search
                                  • Get Qt Extensions
                                  • Unsolved