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. Building an Android app with Qmake on Windows
Qt 6.11 is out! See what's new in the release blog

Building an Android app with Qmake on Windows

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
7 Posts 2 Posters 4.6k Views
  • 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.
  • aalexA Offline
    aalexA Offline
    aalex
    wrote on last edited by
    #1

    Hi,
    Did anyone succeed in building an Android app with Qmake on Windows? I have been trying for a while, by now. It works well with Qt Creator 5.7, and I've copy-pasted the command lines it calls. Here they are: (DOS-like Windows shell)

    set ANDROID_NDK_ROOT=C:\Users\aalex\src\SOFTEXT\Android\android-ndk\r12b
    set JAVA_HOME="C:\Users\aalex\src\SOFTEXT\Android\jdk1.7.0_55"
    set ANDROID_NDK_HOST="windows"
    C:\Users\aalex\src\SOFTEXT\Qt\5.7\android_armv7\bin\qmake.exe -spec android-g++ "CONFIG+=qtquickcompiler" -o Makefile My_Project.pro
    C:\Users\aalex\src\SOFTEXT\Android\mingw530_32\bin\mingw32-make.exe
    "C:\Users\aalex\src\SOFTEXT\Android\Qt\5.7\android_armv7\bin\androiddeployqt.exe" --input C:\Users\aalex\src\softdev\Home\build-My_Project-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Release\My_Project\android-libMy_Project.so-deployment-settings.json --output C:\Users\aalex\src\softdev\Home\build-My_Project-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Release\android-build --deployment bundled --android-platform android-23 --jdk "C:\Users\aalex\src\SOFTEXT\Android\jdk1.7.0_55" --ant C:\Users\aalex\src\SOFTEXT\Android\apache-ant-1.9.7\bin\ant.bat
    

    Now, at the first step, when calling qmake.exe, it complains:

    Le chemin d`accès spécifié est introuvable.
    Project ERROR: You need to set the ANDROID_NDK_ROOT environment variable to point to your Android NDK.
    Could not read qmake configuration file C:/Users/aalex/src/SOFTEXT/Qt/5.7/android_armv7/mkspecs/android-g++/qmake.conf.
    Error processing project file: My_Project.pro
    

    By searching online, I found a bug ticket saying that this message about ANDROID_NDK_ROOT not being set could be due to another variable left unset: ANDROID_NDK_HOST, though both are set here.

    How can I get rid of this error message and move forward with building the app? This error message could be more informative, for sure. Any help is much appreciated.
    Thank you.

    1 Reply Last reply
    0
    • aalexA Offline
      aalexA Offline
      aalex
      wrote on last edited by
      #2

      @aalex said:

      Le chemin d`accès spécifié est introuvable.

      Note: this means that the file is not found.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mvuori
        wrote on last edited by
        #3

        I have no knowledge about this problem, but I notice the quotation marks in
        set ANDROID_NDK_HOST="windows"
        which have a "smell" of a problem. If the system doesn't expect and handle them, it could see the variable as unparsed and thus "unset"...

        1 Reply Last reply
        0
        • aalexA Offline
          aalexA Offline
          aalex
          wrote on last edited by
          #4

          The quotation marks are fine.

          1 Reply Last reply
          0
          • aalexA Offline
            aalexA Offline
            aalex
            wrote on last edited by
            #5

            I had to edit the variables in the Registry: no workaround worked so far.

            Here are some configuration variables:

            :: Variables. (please edit - match the paths to the SVN repositories)
            SET SOFTEXT_PATH=C:\Users\aquessy\src\SOFTEXT
            SET SOFTDEV_PATH=C:\Users\aquessy\src\softdev
            

            Then, I set the environment in the Registry:

            :: Set environment variables into the registry.
            SETX ANDROID_NDK_ROOT %SOFTEXT_PATH%\Android\android-ndk-r12b
            
            SETX JAVA_HOME %SOFTEXT_PATH%\Android\jdk1.7.0_55
            
            SETX ANDROID_NDK_HOST "windows-x86_64"
            
            :: Create a hard link, since the toolchain folder has been badly named, it seems
            IF EXIST %SOFTEXT_PATH%\Android\android-ndk-r12b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows (
                ECHO "No need to create a hard link"
            ) ELSE (
                ECHO "Creating a hard link"
                MKLINK /J %SOFTEXT_PATH%\Android\android-ndk-r12b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows %SOFTEXT_PATH%\Android\android-ndk-r12b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64
            )
            
            ECHO "The environment variables are now set in the registry. Please start a new command prompt so that they take effect."
            

            Next, launch a new command prompt, (a Windows terminal) and build the Android app:

            :: Call qmake, make and androiddeployqt
            PUSHD %SOFTDEV_PATH%\Home\HEMC_Control_App
            
            %SOFTEXT_PATH%\Qt\5.7\android_armv7\bin\qmake.exe -spec android-g++ "CONFIG+=qtquickcompiler" -o Makefile HEMC_Control_App.pro
            
            %SOFTEXT_PATH%\Android\mingw530_32\bin\mingw32-make.exe
            
            %SOFTEXT_PATH%\Qt\5.7\android_armv7\bin\androiddeployqt.exe --input %SOFTDEV_PATH%\Home\build-HEMC_Control_App-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Release\HEMC_Control_App\android-libHEMC_Control_App.so-deployment-settings.json --output %SOFTDEV_PATH%\Home\build-HEMC_Control_App-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Release\android-build --deployment bundled --android-platform android-23 --jdk %SOFTEXT_PATH%\Android\jdk1.7.0_55 --ant %SOFTEXT_PATH%\Android\apache-ant-1.9.7\bin\ant.bat
            
            POPD
            

            Finally, we can cleanup the environment variables we set in the Registry:

            :: Delete environment variables from the registry.
            REG delete HKEY_CURRENT_USER\Environment /v ANDROID_NDK_ROOT
            
            REG delete HKEY_CURRENT_USER\Environment /v JAVA_HOME
            
            REG delete HKEY_CURRENT_USER\Environment /v ANDROID_NDK_HOST
            

            It works!

            Now, is there a more standard way - or simpler way - to do this?
            Best,

            1 Reply Last reply
            0
            • aalexA Offline
              aalexA Offline
              aalex
              wrote on last edited by
              #6

              Hi,
              I've tried on another computer, and now, when make runs this command:

              C:\Users\aalex\src\softdev\Home\My_Project>C:\Users\aalex\src\SOFTEXT\Qt\5.7\android_armv7\bin\androiddeployqt.exe --input C:\Users\aalex\src\softdev\Home\build-My_Project-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Release\My_Project\android-libMy_Project.so-deployment-settings.json --output C:\Users\aalex\src\softdev\Home\build-My_Project-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Release\android-build --deployment bundled --android-platform android-23 --jdk C:\Users\aalex\src\SOFTEXT\Android\jdk1.7.0_55 --ant C:\Users\aalex\src\SOFTEXT\Android\apache-ant-1.9.7\bin\ant.bat 
              

              I get this error:

              Cannot read from input file: C:\Users\aalex\src\softdev\Home\build-My_Project-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Release\My_Project\android-libMy_Project.so-deployment-settings.json
              

              Does someone knows why this file has maybe not been generated?

              1 Reply Last reply
              0
              • aalexA Offline
                aalexA Offline
                aalex
                wrote on last edited by
                #7

                The Qt and Android utilities are not installed on a system-wide standard path on that computer. So, I thought I might want to add these directories to the PATH environment variable.

                See https://forum.qt.io/topic/38255/solved-cannot-read-from-input-file-android-lib-so-deployment-settings-json/2

                So, I set my PATH: (but it still doesn't work)

                :: Check if our bin path is already in PATH
                :: Add it if not. (permanently change it in the registry)
                :: See HKEY_CURRENT_USER/Environment/PATH
                SET PATH_ANDROID_BIN="%SOFTEXT_PATH%\Android\android-sdk\build-tools"
                SET PATH_MINGW_BIN="%SOFTEXT_PATH%\Android\mingw530_32\bin"
                SET PATH_QT_BIN="%SOFTEXT_PATH%\Qt\5.7\android_armv7\bin"
                SET PATHTOADD="%PATH_MINGW_BIN%;%PATH_QT_BIN%;%PATH_ANDROID_BIN%"
                ECHO "%PATH" | FIND /C:"%PATHTOADD%" >nul & IF ERRORLEVEL 1 (
                    ECHO "The path to the Android utils is a already in PATH"
                    ECHO "PATH: %PATH%"
                ) else (
                    ECHO "Adding the path to the Android utils to PATH"
                    ECHO "Beware that the PATH cannot have more than 1024 characters."
                    :: Note that the separator is ";"
                    SETX PATH "%PATH%;%PATHTOADD%"
                    ECHO "New PATH: %PATH%"
                )
                
                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