Sur cette page

L'outil androiddeployqt

La construction d'un paquetage Android implique de nombreuses étapes, c'est pourquoi Qt est livré avec un outil qui gère le travail pour vous. Les étapes gérées par l'outil androiddeployqt sont décrites dans Déployer une application sur Android.

Conditions préalables à l'exécution de androiddeployqt

Avant d'exécuter l'outil manuellement, vous devez configurer votre projet avec CMake ou qmake pour générer Makefiles et un fichier JSON (c'est-à-dire android-<target_name>-deployment-settings.json) contenant des paramètres importants utilisés par androiddeployqt.

Note : Il n'est pas recommandé de modifier le fichier JSON de androiddeployqt.

Pour préparer l'environnement pour androiddeployqt, configurez votre projet dans un répertoire distinct de votre répertoire source. Pour plus d'informations sur la configuration de votre projet, voir Construire des projets Qt pour Android à partir de la ligne de commande.

Arguments de la ligne de commande

Les seuls arguments de ligne de commande requis lors de l'exécution de l'outil sont --input et --output. Les autres arguments de la ligne de commande sont facultatifs mais utiles. La liste ci-dessous est disponible en passant l'argument --help à androiddeployqt.

Syntax: androiddeployqt --output <destination> [options]

Creates an Android package in the build directory <destination> and
builds it into an .apk file.

Optional arguments:
    --input <inputfile>: Reads <inputfile> for options generated by
       qmake. A default file name based on the current working
       directory will be used if nothing else is specified.

    --deployment <mechanism>: Supported deployment mechanisms:
       bundled (default): Includes Qt files in stand-alone package.
       unbundled: Assumes native libraries are present on the device
       and does not include them in the APK.

    --aab: Build an Android App Bundle.

    --no-build: Do not build the package, it is useful to just install
       a package previously built.

    --install: Installs apk to device/emulator. By default this step is
       not taken. If the application has previously been installed on
       the device, it will be uninstalled first.

    --reinstall: Installs apk to device/emulator. By default this step
       is not taken. If the application has previously been installed on
       the device, it will be overwritten, but its data will be left
       intact.

    --device [device ID]: Use specified device for deployment. Default
       is the device selected by default by adb.

    --android-platform <platform>: Builds against the given android
       platform. By default, the highest available version will be
       used.

    --release: Builds a package ready for release. By default, the
       package will be signed with a debug key.

    --sign <url/to/keystore> <alias>: Signs the package with the
       specified keystore, alias and store password.
       Optional arguments for use with signing:
         --storepass <password>: Keystore password.
         --storetype <type>: Keystore type.
         --keypass <password>: Password for private key (if different
           from keystore password.)
         --sigfile <file>: Name of .SF/.DSA file.
         --digestalg <name>: Name of digest algorithm. Default is
           "SHA-256".
         --sigalg <name>: Name of signature algorithm. Default is
           "SHA256withRSA".
         --tsa <url>: Location of the Time Stamping Authority.
         --tsacert <alias>: Public key certificate for TSA.
         --internalsf: Include the .SF file inside the signature block.
         --sectionsonly: Do not compute hash of entire manifest.
         --protected: Keystore has protected authentication path.
         --jarsigner: Deprecated, ignored.

       NOTE: To conceal the keystore information, the environment variables
         QT_ANDROID_KEYSTORE_PATH, and QT_ANDROID_KEYSTORE_ALIAS are used to
         set the values keysotore and alias respectively.
         Also the environment variables QT_ANDROID_KEYSTORE_STORE_PASS,
         and QT_ANDROID_KEYSTORE_KEY_PASS are used to set the store and key
         passwords respectively. This option needs only the --sign parameter.

    --jdk <path/to/jdk>: Used to find the jarsigner tool when used
       in combination with the --release argument. By default,
       an attempt is made to detect the tool using the JAVA_HOME and
       PATH environment variables, in that order.

    --qml-import-paths: Specify additional search paths for QML
       imports.

    --verbose: Prints out information during processing.

    --no-generated-assets-cache: Do not pregenerate the entry list for
       the assets file engine.

    --aux-mode: Operate in auxiliary mode. This will only copy the
       dependencies into the build directory and update the XML templates.
       The project will not be built or installed.

    --apk <path/where/to/copy/the/apk>: Path where to copy the built apk.

    --build-aar: Build an AAR package. This option skips --aab, --install,
       --reinstall, and --sign options if they are provided.

    --qml-importscanner-binary <path/to/qmlimportscanner>: Override the
       default qmlimportscanner binary path. By default the
       qmlimportscanner binary is located using the Qt directory
       specified in the input file.

    --depfile <path/to/depfile>: Output a dependency file.

    --builddir <path/to/build/directory>: build directory. Necessary when
       generating a depfile because ninja requires relative paths.

    --no-rcc-bundle-cleanup: skip cleaning rcc bundle directory after
       running androiddeployqt. This option simplifies debugging of
       the resource bundle content, but it should not be used when deploying
       a project, since it litters the "assets" directory.

    --copy-dependencies-only: resolve application dependencies and stop
       deploying process after all libraries and resources that the
       application depends on have been copied.

    --help: Displays this information.

Avec un project_name, pour construire le paquet d'application avec androiddeployqt sans le déployer sur l'appareil, exécutez ce qui suit :

androiddeployqt --input <build_dir>/android-project_name-deployment-settings.json \
                --output <build_dir>/android-build

Pour construire et déployer le paquetage sur l'appareil :

androiddeployqt --input <build_dir>/android-project_name-deployment-settings.json \
                --output <build_dir>/android-build --install --device <device_serial_id>

Détection des dépendances

Qt est livré avec un certain nombre de plugins qui sont chargés à l'exécution lorsqu'ils sont nécessaires. Ceux-ci peuvent gérer n'importe quoi, de la connexion à des bases de données SQL au chargement de formats d'images spécifiques. Détecter les dépendances des plugins est impossible car les plugins sont chargés à l'exécution, mais androiddeployqt essaie de deviner ces dépendances en se basant sur les dépendances Qt de votre application. Si le plugin a des dépendances Qt qui ne sont pas aussi des dépendances de votre application, il ne sera pas inclus par défaut. Par exemple, pour s'assurer que le plugin de format d'image SVG est inclus, vous devrez ajouter le module Qt SVG à votre projet pour qu'il devienne une dépendance de votre application :

find_package(Qt6 REQUIRED COMPONENTS Svg)
...
target_link_libraries(target_name PRIVATE Qt6::Svg)

Si vous vous demandez pourquoi un plugin particulier n'est pas inclus automatiquement, vous pouvez exécuter androiddeployqt avec l'option --verbose pour obtenir la liste des dépendances manquantes pour chaque plugin exclu. Vous pouvez faire la même chose dans Qt Creator en cochant la case Verbose output dans les pages Projects > Build Steps > Build Android APK > Advanced Actions.

Il est également possible de spécifier manuellement les dépendances de votre application. Pour plus d'informations, voir la variable CMake QT_ANDROID_DEPLOYMENT_DEPENDENCIES.

Remarque : androiddeployqt analyse les fichiers QML du projet pour collecter les importations QML. Cependant, si vous chargez du code QML en tant que QString à partir de C++ au moment de l'exécution, cela peut ne pas fonctionner correctement car androiddeployqt n'en aura pas connaissance au moment du déploiement. Pour y remédier, vous pouvez ajouter un fichier QML factice qui importe les modules QML référencés au moment de l'exécution.

Déploiement dans Qt Creator

Qt Creator utilise androiddeployqt sous le capot, et fournit des interfaces utilisateur simples et intuitives pour spécifier diverses options. Pour plus d'informations, voir Qt Creator: Android Deploy Configuration.

Pour plus d'informations sur la personnalisation et le déploiement d'une application Qt pour Android, voir Déployer une application sur Android.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.