Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

building qt 5.9 on windows for android results in 'ERROR: Cannot detect Android NDK toolchain'



  • I followed the build instructions from here :
    https://wiki.qt.io/Building_qt-android_on_windows

    and created my bat file to ease the operation

    set "MINGW_BUILDS_ROOT=C:\mingw64"
    set "JDK_ROOT=E:\programs\AndStdio\jre"
    set "ANDROID_NDK_PATH=E:\programs\AndNdk"
    set "ANDROID_SDK_PATH=E:\programs\AndSdk2"
    set "ANDROID_API_VERSION=android-21"
    set "ANDROID_SDK_ROOT=%ANDROID_SDK_PATH%"
    set "ANDROID_TARGET_ARCH=armeabi-v7a"
    set "ANDROID_BUILD_TOOLS_REVISION=21.1.2"
    set "ANDROID_TOOLCHAIN_VERSION=4.9"
    set "ANDROID_NDK_HOST=windows-x86_64"
    set "PATH=%MINGW_BUILDS_ROOT%\bin;%PATH%"
    configure.bat -developer-build -platform win32-g++ -opengl es2 -xplatform android-g++ -android-ndk ANDROID_NDK_PATH -android-sdk ANDROID_SDK_ROOT -opensource -confirm-license -nomake tests -nomake examples -prefix E:\qt-android
    

    but I got :

    Bootstrapping qmake ...
    mingw32-make: Nothing to be done for 'first'.
    ERROR: Cannot detect Android NDK toolchain.
    Please use -android-toolchain-version to specify it.
    

    I'm using android-ndk-r17b-windows-x86_64 downloaded from https://dl.google.com/android/repository/android-ndk-r17b-windows-x86_64.zip and can successfully build android apps with visualgdb in visual studio


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Please also take a look at this wiki entry linked from Qt's documentation. You should try with NDK r10. The more recent versions proven problematic as explained there.

    You might have success with r17 with a more recent version of Qt.



  • but what are the more recent versions , I'm currently using qt 5.9
    I'll try with ndk r10 and post the result



  • the same problem with ndk 10
    this is my bat file :

    @echo off
    set "MINGW_BUILDS_ROOT=C:\mingw64"
    set "JDK_ROOT=E:\programs\AndStdio\jre"
    set "ANDROID_NDK_PATH=E:\programs\NDK10"
    set "ANDROID_SDK_PATH=E:\programs\AndSdk2"
    set "ANDROID_API_VERSION=android-21"
    set "ANDROID_SDK_ROOT=%ANDROID_SDK_PATH%"
    set "ANDROID_TARGET_ARCH=armeabi-v7a"
    set "ANDROID_BUILD_TOOLS_REVISION=21.1.2"
    set "ANDROID_TOOLCHAIN_VERSION=4.9"
    set "ANDROID_NDK_HOST=windows-x86_64"
    set "PATH=%MINGW_BUILDS_ROOT%\bin;%PATH%"
    configure.bat -developer-build -platform win32-g++ -opengl es2 -xplatform android-g++ -android-ndk ANDROID_NDK_PATH -android-toolchain-version 4.9 -android-sdk ANDROID_SDK_ROOT -opensource -confirm-license -nomake tests -nomake examples -prefix E:\qt-android
    

    and the output is :

    Bootstrapping qmake ...
    mingw32-make: Nothing to be done for 'first'.
    ERROR: Cannot detect Android NDK toolchain.
    Please use -android-toolchain-version to specify it.

  • Lifetime Qt Champion

    Out of curiosity, why not use a pre-built version ?

    You can make the configure script more verbose adding the -v option.



  • the problem was in this : "-android-ndk ANDROID_NDK_PATH" I had to provide the full path or use %ANDROID_NDK_PATH% as the string was passed as it is not as an environment variable
    I think the error should be : can't find ndk path


  • Lifetime Qt Champion

    So you succeed building Qt ?



  • I now started the build with mingw32-make and the build will take some time



  • got this error during build

    E:/programs/NDK10/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ -c -D__ANDROID_API__=16 --sysroot=E:/programs/NDK10/platforms/android-16/arch-arm/ -isystem E:/programs/NDK10/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem E:/programs/NDK10/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -fstack-protector-strong -DANDROID -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -fno-builtin-memmove -g -g -marm -O0 -fPIC -std=c++14 -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -Werror -Wno-error=cpp -Wno-error=deprecated-declarations -Wno-error=strict-overflow -Wno-error=literal-suffix -D_REENTRANT -DQT_NO_CAST_FROM_ASCII -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_BUILD_FONTDATABASE_SUPPORT_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_NO_EXCEPTIONS -DQT_GUI_LIB -DQT_CORE_LIB -I. -I../../../include -I../../../include/QtFontDatabaseSupport -I../../../include/QtFontDatabaseSupport/5.9.2 -I../../../include/QtFontDatabaseSupport/5.9.2/QtFontDatabaseSupport -I../../../include/QtGui/5.9.2 -I../../../include/QtGui/5.9.2/QtGui -I../../../include/QtCore/5.9.2 -I../../../include/QtCore/5.9.2/QtCore -I../../../include/QtGui -I../../../include/QtCore -I.moc -I../../3rdparty/freetype/include -I../../../mkspecs/android-g++ -o .obj/qfreetypefontdatabase.obj freetype/qfreetypefontdatabase.cpp
    In file included from freetype/qfreetypefontdatabase.cpp:51:0:
     ../../../include/QtFontDatabaseSupport/5.9.2/QtFontDatabaseSupport/private/qfontengine_ft_p.h:1:88: fatal error: ../../../../../src/platformsupport/fontdatabases/freetype/qfontengine_ft_p.h: No such file or directory
    #include "../../../../../src/platformsupport/fontdatabases/freetype/qfontengine_ft_p.h"
                                                                                        ^
    compilation terminated.

  • Lifetime Qt Champion

    Did you check if you have that file somewhere ?



  • @deveLoper5122 said in building qt 5.9 on windows for android results in 'ERROR: Cannot detect Android NDK toolchain':

    qfontengine_ft_p

    I have it in E:\qt-android-source\qt-everywhere-opensource-src-5.9.2\qt-everywhere-opensource-src-5.9.2\qtbase\src\platformsupport\fontdatabases\freetype

    but don't know why the compiler didn't resolve it


  • Lifetime Qt Champion

    That's a pretty long path for not much benefit.

    I'd recommend shortening it and also make an out of source build.



  • I can't change the dir now after I started building , I had to rebuild from scratch again right ?


  • Lifetime Qt Champion

    Yes, that's correct.



  • I could change the dir with a symbol link to qt base and resumed the build again



  • but now I got :

    javac -source 6 -target 6 -Xlint:unchecked -bootclasspath E:/programs/AndSdk2/platforms/android-25/android.jar -cp 'E:\qt-android-source\qt-5.9.2\qt-5.9.2\qtbase\src\android\jar\src\;E:\programs\AndSdk2\platforms\android-25\android.jar' -d .classes.bundled src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java src/org/qtproject/qt5/android/accessibility/QtNativeAccessibility.java src/org/qtproject/qt5/android/QtActivityDelegate.java src/org/qtproject/qt5/android/QtEditText.java src/org/qtproject/qt5/android/QtInputConnection.java src/org/qtproject/qt5/android/QtLayout.java src/org/qtproject/qt5/android/QtMessageDialogHelper.java src/org/qtproject/qt5/android/QtNative.java src/org/qtproject/qt5/android/QtNativeLibrariesDir.java src/org/qtproject/qt5/android/QtSurface.java src/org/qtproject/qt5/android/ExtractStyle.java src/org/qtproject/qt5/android/EditMenu.java src/org/qtproject/qt5/android/EditPopupMenu.java src/org/qtproject/qt5/android/CursorHandle.java
    process_begin: CreateProcess(NULL, javac -source 6 -target 6 -Xlint:unchecked -bootclasspath E:/programs/AndSdk2/platforms/android-25/android.jar -cp E:\qt-android-source\qt-5.9.2\qt-5.9.2\qtbase\src\android\jar\src\;E:\programs\AndSdk2\platforms\android-25\android.jar -d .classes.bundled src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java src/org/qtproject/qt5/android/accessibility/QtNativeAccessibility.java src/org/qtproject/qt5/android/QtActivityDelegate.java src/org/qtproject/qt5/android/QtEditText.java src/org/qtproject/qt5/android/QtInputConnection.java src/org/qtproject/qt5/android/QtLayout.java src/org/qtproject/qt5/android/QtMessageDialogHelper.java src/org/qtproject/qt5/android/QtNative.java src/org/qtproject/qt5/android/QtNativeLibrariesDir.java src/org/qtproject/qt5/android/QtSurface.java src/org/qtproject/qt5/android/ExtractStyle.java src/org/qtproject/qt5/android/EditMenu.java src/org/qtproject/qt5/android/EditPopupMenu.java src/org/qtproject/qt5/android/CursorHandle.java, ...) failed.
    make (e=2): The system cannot find the file specified.


  • the file exists but the javac doesn't seem to be redircted with the symbol link so I have to restart the whole build with a shorter path


Log in to reply