このページでは、Android 用の Unity アプリケーションをビルドする方法と、ビルドする際の考慮点を説明しています。Android 用のビルドプロセスと、Unity の使用するツールについては、Unity が Android 用アプリケーションをビルドする方法 を参照してください。
アプリケーションをビルドする代わりに、Unity プロジェクトを Gradle プロジェクトとしてエクスポートし、それを Android Studio にインポートすることもできます。これは、ビルドパイプラインをより精密に制御したい場合や、Unity がアプリケーション用に生成する Android App Manifest を確認または変更したい場合、あるいは Unity 搭載の機能を別の Android アプリケーションに統合する 場合に役立ちます。詳細は Android プロジェクトのエクスポート を参照してください。
Android アプリケーションをホストするデジタル配信サービスの中には、特定の要件を課しているものがあり、これがビルドプロセスに影響する場合があります。例えば Google Play の場合、アプリケーションは APK ではなく Android App Bundle (AAB) である必要があります。特定のデジタル配信サービスをターゲットにビルドする場合は、まずその デジタル配信サービス のドキュメントを参照し、異なる要件を確認してください。
一部のデジタル配信サービスには、アプリケーションの初期インストールサイズの制限があります。Unity には、インストールサイズの最適化に使用できる方法が複数あります。詳細は 配信サイズの最適化 を参照してください。
デバッグ目的でアプリケーションをビルドする場合は、アプリケーションにパッチを適用することで、ビルドに掛かる時間を短縮できます。詳細は アプリケーションへのパッチ適用 を参照してください。
ビルドを作成する前に、希望のランタイム設定およびビルドシステムプロパティでアプリケーションがビルドされるように、プロジェクトの設定を行ってください。Unity ビルドの設定は、以下の 2 つの設定セットによって構成されます。
Unity は、以下の公開形式で Android アプリケーションをビルドすることができます。
デフォルトでは Unity は APK 公開形式で Android アプリケーションをビルドします。AAB としてAndroid アプリケーションをビルドするための設定は、以下の手順で行えます。
Android 用に Unity アプリケーションをビルドするには、以下を行ってください。
Build and Run を選択すると、Unity はビルド作成時に以下を実行します。
ヒント: 出力パスの初回指定後は、Ctrl+B (macOS では Cmd+B) のキーボードショートカットでアプリケーションをビルドして実行 (Build and Run) できます。
Android アプリケーションを Android 端末で実行するには、デジタル署名が必要です。アプリケーションへの署名には、以下の 2 種類があります。
カスタム署名情報を提供するには、キーストアを作成 し、それを Publishing Settings 内に読み込んでください。
カスタム署名情報が提供された際、Unity はセキュリティ上の理由から、キーストアとキーパスワードをディスクに保存しません。つまり、Unity エディターを再起動するたびにキーパスワードを再入力する必要があります。パスワードを入力せずにアプリケーションをビルドしようとすると、ビルドプロセスが失敗します。Unity エディターを開くたびにパスワードを入力しなくて済むようにするには、公開用のアプリケーションをビルドする時にだけカスタム署名情報を提供するのがベストプラクティスです。デバイス上でテストするためのビルドを作成する場合にはカスタム署名情報を提供せず、代わりにデバッグ署名を使用します。
アプリケーションへの署名に関する詳細は、アプリへの署名 を参照してください。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.