Search code examples
qtcmakeqtandroidextras

Error in building Qt application on Android


first, I should say that I can create a new project and build and run it on my Android device, but I have a problem with one of my projects, Compile output says:

06:20:09: Running steps for project MusiQ...
06:20:09: Skipping disabled step Copy application data.
06:20:09: Starting: "F:\Qt\Tools\CMake_64\bin\cmake.exe" --build . --target MusiQ
jom: parallel job execution disabled for Makefile
[  5%] Automatic MOC and UIC for target MusiQ
[  5%] Built target MusiQ_autogen
[100%] Built target MusiQ
06:20:10: The process "F:\Qt\Tools\CMake_64\bin\cmake.exe" exited normally.
06:20:10: Starting: "F:\Qt\5.15.0\android\bin\androiddeployqt.exe" --input F:/project/MusiQ/build-MusiQ-Android_for_armeabi_v7a_arm64_v8a_x86_x86_64_Clang_Qt_5_15_0_for_Android-Release/android_deployment_settings.json --output F:/project/MusiQ/build-MusiQ-Android_for_armeabi_v7a_arm64_v8a_x86_x86_64_Clang_Qt_5_15_0_for_Android-Release/android-build --android-platform android-29 --jdk "C:/Program Files/Java/jdk1.8.0_271" --gradle
Cannot find application binary MusiQ.
06:20:10: The process "F:\Qt\5.15.0\android\bin\androiddeployqt.exe" exited with code 2.
Error while building/deploying project MusiQ (kit: Android for armeabi-v7a,arm64-v8a,x86,x86_64 (Clang Qt 5.15.0 for Android))
When executing step "Build Android APK"
06:20:10: Elapsed time: 00:01.

I don't know if there is something wrong with line 2, skipping disabled step copy...

but after starting androiddeployqt.exe, in line 10, logs says: Cannot find application binary

I have no idea how to solve this because actually, I have MusiQ binary file in the generated files after compilation, also as I said earlier, I can run and deploy other projects on my Android device so I think there is no problem with Qt-Android configuration in QtCreator,

Any idea how to solve this problem? Thank you


Solution

  • solved, it was my fault:

    I should add library instead of executable for android device:

    if (WIN32)
        add_executable(target ${target_SOURCES} ${QRC_FILE} ${target_HEADERS})
    elseif(ANDROID)
        add_library(target SHARED
            ${target_SOURCES} ${QRC_FILE} ${target_HEADERS}
        )
    endif()