QT_ANDROID_EXTRA_LIBS

Extra libraries to deploy with the target.

This property was introduced in Qt 6.0.

Note: This property is in technology preview and may change in future releases.

Note: This property is used only if targeting the Android platform.

A list of external libraries that will be copied into your application's libs folder and loaded on start-up. This can be used, for instance, to enable OpenSSL in your application. For more information, see Adding OpenSSL Support for Android.

When adding extra libraries from the build tree of your project, it's also necessary to add dependency relations between library and the application target. Using the following project structure may cause an issue, when deploying an apk:

 qt_add_executable(MyApp main.cpp)

 set_target_properties(MyApp PROPERTIES
     QT_ANDROID_EXTRA_LIBS
         ${CMAKE_CURRENT_BINARY_DIR}/libMyService_${ANDROID_ABI}.so
 )

 # MyService library doesn't have any relations with MyApp
 qt_add_library(MyService service.cpp)

This leads to uncertainty whether MyService library will be available before the deployment of MyApp or not. The easiest solution is adding MyService library to the MyApp dependencies:

 add_dependencies(MyApp MyService)

When adding per-architecture libraries to a multi-abi project, list all their paths explicitly, rather than rely on variables like CMAKE_ANDROID_ARCH_ABI to dynamically compute the paths.

Prefer:

 set(libs
     ${CMAKE_CURRENT_BINARY_DIR}/libA_x86so
     ${CMAKE_CURRENT_BINARY_DIR}/libA_x86_64.so
     ${CMAKE_CURRENT_BINARY_DIR}/libA_arm64-v8a.so
     ${CMAKE_CURRENT_BINARY_DIR}/libA_armeabi-v7a.so
 )
 set_target_properties(MyApp PROPERTIES QT_ANDROID_EXTRA_LIBS ${libs})

 # When targeting precompiled libs
 target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC libA_${ANDROID_ABI})

over:

 set_target_properties(MyApp PROPERTIES
     QT_ANDROID_EXTRA_LIBS
         ${CMAKE_CURRENT_BINARY_DIR}/libA_${CMAKE_ANDROID_ARCH_ABI}.so)

See also qt_android_generate_deployment_settings().