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

PendingIntent.FLAG_MUTABLE not found while building QT 6.2.2 for Android



  • Tried to build QT for Android on Windows with the following configuration:

    set "ANDROID_SDK_ROOT=C:\Users\D-Ef\AppData\Local\Android\Sdk"
    set "ANDROID_NDK_PATH=C:\Users\D-Ef\AppData\Local\Android\Sdk\ndk\23.1.7779620"
    rem See qtbase\mkspecs\android-clang\qmake.conf
    rem see %ANDROID_SDK_ROOT%\build-tools folder
    set "ANDROID_BUILD_TOOLS_REVISION=31.0.0"
    
    configure.bat -platform win32-msvc -xplatform android-clang -prefix %MY_INSTALL_PATH% -qt-host-path %QT_HOST_PATH% ^
      -android-sdk %ANDROID_SDK_ROOT% -android-ndk %ANDROID_NDK_PATH% -android-ndk-platform android-23 -android-abis x86_64 ^
      -DQT_NO_EXCEPTIONS=1 -release -force-debug-info -opensource -confirm-license
    
    cmake --build . --parallel
    

    and got this error:

    [5001/7411] Building Java objects for Qt6AndroidNfc.jar
    FAILED: qtconnectivity/src/android/nfc/CMakeFiles/Qt6AndroidNfc.dir/java_compiled_Qt6AndroidNfc E:/repos/qt-everywhere-src-6.2.2/qtconnectivity/src/android/nfc/CMakeFiles/Qt6AndroidNfc.dir/java_compiled_Qt6AndroidNfc
    cmd.exe /C "cd /D E:\repos\qt-everywhere-src-6.2.2\qtconnectivity\src\android\nfc && E:\PFiles\cmake-3.21.3-windows-x86_64\bin\cmake.exe -DCMAKE_JAVA_CLASS_OUTPUT_PATH=E:/repos/qt-everywhere-src-6.2.2/qtconnectivity/src/android/nfc/CMakeFiles/Qt6AndroidNfc.dir -DCMAKE_JAR_CLASSES_PREFIX= -P E:/PFiles/cmake-3.21.3-windows-x86_64/share/cmake-3.21/Modules/UseJava/ClearClassFiles.cmake && "C:\Program Files\Java\jdk1.8.0_301\bin\javac.exe" -source 8 -target 8 -Xlint:unchecked -bootclasspath C://Users//D-Ef//AppData//Local//Android//Sdk/platforms/android-30/android.jar -classpath ;E:/repos/qt-everywhere-src-6.2.2/qtconnectivity/src/android/nfc;E:/repos/qt-everywhere-src-6.2.2/qtbase/jar;C://Users//D-Ef//AppData//Local//Android//Sdk/platforms/android-30/android.jar -d E:/repos/qt-everywhere-src-6.2.2/qtconnectivity/src/android/nfc/CMakeFiles/Qt6AndroidNfc.dir @E:/repos/qt-everywhere-src-6.2.2/qtconnectivity/src/android/nfc/CMakeFiles/Qt6AndroidNfc.dir/java_sources && E:\PFiles\cmake-3.21.3-windows-x86_64\bin\cmake.exe -E touch E:/repos/qt-everywhere-src-6.2.2/qtconnectivity/src/android/nfc/CMakeFiles/Qt6AndroidNfc.dir/java_compiled_Qt6AndroidNfc"
    src\org\qtproject\qt\android\nfc\QtNfc.java:89: error: cannot find symbol
            int flags = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) ? PendingIntent.FLAG_MUTABLE
                                                                     ^
      symbol:   variable S
      location: class VERSION_CODES
    src\org\qtproject\qt\android\nfc\QtNfc.java:89: error: cannot find symbol
            int flags = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) ? PendingIntent.FLAG_MUTABLE
                                                                                        ^
      symbol:   variable FLAG_MUTABLE
      location: class PendingIntent
    2 errors
    

    what can be wrong with the configuration?

    My configure.bat output:

    Configuring 'qtbase'
    -- Using Android SDK API android-30 from C://Users//D-Ef//AppData//Local//Android//Sdk/platforms
    -- Found Java: C:/Program Files/Java/jdk1.8.0_301/bin/java.exe (found suitable version "1.8.0.301", minimum required is "1.8") found components: Development
    -- Check for feature set changes
    -- Building architecture extraction project with the following CMake arguments:
        -DANDROID_ABI=x86_64
        -DANDROID_ARM_MODE=thumb
        -DANDROID_ARM_NEON=TRUE
        -DANDROID_PLATFORM=android-21
        -DANDROID_STL=c++_shared
        -DANDROID_TOOLCHAIN=clang
        -DCMAKE_ANDROID_STL_TYPE=c++_shared
        -DCMAKE_OBJCOPY=C:/Users/D-Ef/AppData/Local/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/windows-x86_64/bin/llvm-objcopy.exe
        -DCMAKE_TOOLCHAIN_FILE=C:/Users/D-Ef/AppData/Local/Android/Sdk/ndk/23.1.7779620/build/cmake/android.toolchain.cmake
        -DCMAKE_C_STANDARD=11
        -DCMAKE_CXX_STANDARD=17
        -DCMAKE_MODULE_PATH:STRING=E:/repos/qt-everywhere-src-6.2.2/qtbase/cmake/platforms
    

    also it is not clear why ANDROID_PLATFORM=android-21 if I specified 23.

    I published all the steps on my blog.



  • @Dmitriano it is because SDK API 31 was not installed.


Log in to reply