androiddeployqtツール

Androidパッケージのビルドには多くのステップが必要です。androiddeployqtツールによって処理されるステップは、Android上でアプリケーションをデプロイするで説明されています。

androiddeployqtを実行する前の前提条件

ツールを手動で実行する前に、CMake またはqmake を使ってプロジェクトを構成し、Makefiles と、androiddeployqt で使用される重要な設定を含むJSON ファイル(つまりandroid-<target_name>-deployment-settings.json )を生成する必要があります。

注: androiddeployqt JSON ファイルを変更することは推奨されません。

androiddeployqt 用の環境を準備するために、ソースディレクトリとは別のディレクトリにプロ ジェクトを設定してください。プロジェクトの設定の詳細については、Building Qt for Android Projects from Command Line を参照してください。

コマンドライン引数

ツールを実行する際に必要なコマンドライン引数は--input--output だけです。その他のコマンドライン引数はオプションですが、便利です。以下のリストは、--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.

project_name 、デバイスにデプロイせずにandroiddeployqt 、アプリケーション・パッケージをビルドするには、以下を実行します:

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

パッケージをビルドしてデバイスにデプロイするには、以下を実行します:

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

依存関係の検出

Qt には多くのプラグインが付属しており、必要な時に実行時にロードされます。これらは SQL データベースへの接続から特定の画像フォーマットの読み込みまで、あらゆる処理を行うことができます。プラグインは実行時にロードされるため、プラグインの依存関係を検出することは不可能ですが、androiddeployqt はアプリケーションの Qt 依存関係に基づいて、そのような依存関係を推測しようとします。プラグインがアプリケーションの依存関係でもない Qt 依存関係を持っている場合、それはデフォルトではインクルードされません。例えば、SVG画像フォーマットプラグインを確実にインクルードするには、プロジェクトに Qt SVGモジュールを追加する必要があります:

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

なぜ特定のプラグインが自動的にインクルードされないのか疑問に思ったら、--verbose オプションを付けて androiddeployqt を実行し、除外されたプラグインごとに不足している依存関係のリストを取得することができます。Projects >Build Steps >Build Android APK >Advanced ActionsVerbose output チェックボックスにチェックを入れれば、Qt Creator でも同じことができます。

アプリケーションの依存関係を手動で指定することも可能です。詳細については、QT_ANDROID_DEPLOYMENT_DEPENDENCIESCMake変数を参照してください。

Note: androiddeployqtはプロジェクトのQMLファイルをスキャンしてQMLインポートを収集します。しかし、実行時にC++からQString 、QMLコードをロードしている場合、androiddeployqtはデプロイ時にそれを認識しないため、正しく動作しない可能性があります。これを解決するには、実行時に参照されるQMLモジュールをインポートするダミーのQMLファイルを追加します。

デプロイQt Creator

Qt Creator のデプロイは 、様々なオプションを指定するための簡単で直感的なユーザーインターフェースを提供します。詳しくは、androiddeployqt Qt Creator:Android Deploy Configurationを参照してください。

Qt for Android アプリのカスタマイズとデプロイの詳細については、Android でのアプリケーションのデプロイを参照してください。

© 2025 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.