Unsolved Building an Android app with Qmake on Windows
-
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. -
@aalex said:
Le chemin d`accès spécifié est introuvable.
Note: this means that the file is not found.
-
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"... -
The quotation marks are fine.
-
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, -
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?
-
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.
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%" )