In questa pagina

Lo strumento androiddeployqt

La creazione di un pacchetto Android richiede numerosi passaggi, pertanto Qt include uno strumento che si occupa di eseguire queste operazioni al posto dell'utente. I passaggi gestiti dallo strumento Android Deploy Qt sono descritti nella sezione Distribuzione di un'applicazione su Android.

Prerequisiti prima di eseguire androiddeployqt

Prima di eseguire manualmente lo strumento, è necessario configurare il progetto utilizzando CMake o qmake per generare un file ` Makefiles ` e un file ` JSON ` (ad esempio android-<target_name>-deployment-settings.json) contenente impostazioni importanti utilizzate da androiddeployqt.

Nota: si sconsiglia di modificare il file JSON androiddeployqt.

Per preparare l’ambiente per androiddeployqt, configurare il progetto in una directory separata rispetto alla directory dei sorgenti. Per ulteriori informazioni sulla configurazione del progetto, consultare Creazione di progetti Qt per Android dalla riga di comando.

Argomenti della riga di comando

Gli unici argomenti della riga di comando obbligatori quando si esegue lo strumento sono --input e --output. Gli altri argomenti della riga di comando sono facoltativi ma utili. L'elenco riportato di seguito è disponibile passando l'argomento --help a 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.

Con un'project_name, per compilare il pacchetto dell'applicazione con androiddeployqt senza distribuirlo sul dispositivo, eseguire quanto segue:

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

Per compilare e distribuire il pacchetto sul dispositivo:

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

Rilevamento delle dipendenze

Qt include una serie di plugin che vengono caricati in fase di esecuzione quando necessario. Questi plugin possono gestire qualsiasi operazione, dalla connessione a database SQL al caricamento di formati di immagine specifici. Non è possibile rilevare le dipendenze dei plugin poiché questi vengono caricati in fase di esecuzione, ma androiddeployqt cerca di individuarle in base alle dipendenze Qt della tua applicazione. Se un plugin presenta dipendenze Qt che non sono presenti anche nella tua applicazione, non verrà incluso per impostazione predefinita. Ad esempio, per assicurarsi che il plugin per il formato immagine SVG sia incluso, sarà necessario aggiungere il Qt SVG modulo al proprio progetto affinché diventi una dipendenza dell’applicazione:

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

Se vi state chiedendo perché un determinato plugin non venga incluso automaticamente, potete eseguire androiddeployqt con l’opzione ` --verbose ` per ottenere l’elenco delle dipendenze mancanti per ciascun plugin escluso. È possibile ottenere lo stesso risultato in Qt Creator spuntando la casella di controllo “ Verbose output ” in “ Projects ” > “ Build Steps ” > “ Build Android APK ” > “ Advanced Actions ”.

È inoltre possibile specificare manualmente le dipendenze dell’applicazione. Per ulteriori informazioni, consultare la variabile CMake QT_ANDROID_DEPLOYMENT_DEPENDENCIES.

Nota: androiddeployqt esegue la scansione dei file QML del progetto per raccogliere le importazioni QML. Tuttavia, se si carica codice QML come " QString " da C++ in fase di esecuzione, ciò potrebbe non funzionare correttamente poiché androiddeployqt non ne sarà a conoscenza al momento della distribuzione. Per ovviare a questo problema, è possibile aggiungere un file QML fittizio che importi tali moduli QML a cui si fa riferimento in fase di esecuzione.

Distribuzione in Qt Creator

Qt Creator utilizza androiddeployqt in background e offre interfacce utente semplici e intuitive per specificare varie opzioni. Per ulteriori informazioni, consultare Qt Creator: Configurazione della distribuzione Android.

Per ulteriori informazioni sulla personalizzazione e la distribuzione di un'app Qt per Android, consultare Distribuzione di un'applicazione su 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.