Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

Android用にエクスポート

参考

This page describes how to export a Godot project to Android. If you're looking to compile export template binaries from source instead, read Android用のコンパイル.

Android用のエクスポートは、GodotをAndroid用にコンパイルするよりも必要な条件が少なくなります。Android SDKとエンジンの設定方法を、以下のステップで詳しく説明します。

注意

Projects written in C# can be exported to Android as of Godot 4.2, but support is experimental and some limitations apply.

Install OpenJDK 17

Download and install OpenJDK 17.

Android SDKをダウンロード

AndroidSDKをダウンロードしてインストールします。

  • You can install the Android SDK using Android Studio version 4.1 or later.

    • この方法 でツールの更新を行います。

    • 推奨パッケージ がインストールされていることを確認してください。

      • Android SDK Platform-Tools バージョン 30.0.5以降

      • Android SDK Build-Tools version 33.0.2

      • Android SDK Platform 33

      • Android SDK Command-line Tools (最新版)

      • CMake バージョン 3.10.2.4988404

      • NDK version r23c (23.2.8568313)

  • Alternatively, you can install the Android SDK using the command line tools.

    • コマンドラインツールインストール後、 sdkmanager コマンドでセットアップを完了します:

sdkmanager --sdk_root=<android_sdk_path> "platform-tools" "build-tools;33.0.2" "platforms;android-33" "cmdline-tools;latest" "cmake;3.10.2.4988404" "ndk;23.2.8568313"

注釈

Linux環境では、ディストリビューションのAndroid SDKは古いことが多いので、使用しないでください

デバッグキーストアを作成する

Androidでは、デバイスにインストールし、リリース用ではないAPKを配布するための、デバッグキーストアファイルが必要です。以前にSDKを使用してプロジェクトをビルドしたことがある場合は、antまたはeclipseによって作成済みの可能性があります (Linux 、macOSでは、 ~/.android ディレクトリ、Windowsでは C:\Users\<user>\.android\ ディレクトリ )。

見つからない場合や作成する必要がある場合は、JDKのkeytoolコマンドをこの目的に使用できます:

keytool -keyalg RSA -genkeypair -alias androiddebugkey -keypass android -keystore debug.keystore -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999 -deststoretype pkcs12

This will create a debug.keystore file in your current directory. You should move it to a memorable location such as %USERPROFILE%\.android\, because you will need its location in a later step. For more information on keytool usage, see this Q&A article.

注釈

It is important that the password is the same for the keystore and the key. This is a known Android studio issue that also affects Godot projects.

Godotで設定する

[エディタ設定]画面に移動します。この画面には、コンピュータのユーザー アカウントのエディタ設定が含まれます (プロジェクトから独立しています)。

../../_images/editorsettings.png

Androidの設定が配置されているセクションまで下にスクロールします:

../../_images/androidsdk.png

この画面で、2つのファイルパスを設定する必要があります:

  • Android Sdk Path Android SDK のインストール場所。例 Windowsでは``%LOCALAPPDATA%AndroidSdk``、 macOSでは``/Users/$USER/Library/Android/sdk/`` 。

  • デバック .keystore``ファイル - 上記で作成した ``debug.keystore ファイルを置いたフォルダにあります。

設定が完了すれば、Androidにエクスポートできるようになります!

注釈

If you get an error saying "Could not install to device.", make sure you do not have an application with the same Android package name already installed on the device (but signed with a different key).

If you have an application with the same Android package name but a different signing key already installed on the device, you must remove the application in question from the Android device before exporting to Android again.

ランチャーアイコンの提供

ランチャーアイコンは、Androidランチャーアプリでユーザーにアプリケーションを表すために使用されます。 Godotは高解像度アイコン(xxxhdpi 密度画面用)のみを必要とし、低解像度のバリアントを自動的に生成します。

Godotに必要なアイコンには2つのタイプがあります:

  • Main Icon: The "classic" icon. This will be used on all Android versions up to Android 8 (Oreo), exclusive. Must be at least 192×192 px.

  • Adaptive Icons: Android 8 からは、アダプティブ アイコンが導入されています。ネイティブの見た目にするには、アプリケーションはアイコンを前面と背景に分けて含める必要があります。アイコンのアニメーションとマスキングは、ランチャーによってコントロールされます。最低でも 432x432 ピクセルが必要。

参考

アダプティブ アイコンをデザインする際は、いくつかのルールに従うことが重要です。Google Designが、それらのルールとアダプティブ アイコンの機能について解説するすばらしい記事を公開 (英語)しています。

注意

The most important adaptive icon design rule is to have your icon critical elements inside the safe zone: a centered circle with a diameter of 66dp (264 pixels on xxxhdpi) to avoid being clipped by the launcher.

もし要求されるアイコンを指定しなかった場合、Godotは失敗するたびにフォールバック チェーンから次のものを試し、置き換えます:

  • Main Icon: 指定されたメイン アイコン -> プロジェクト アイコン -> デフォルトのGodotメインアイコン。

  • Adaptive Icon Foreground: 指定された前面アイコン -> 指定されたメイン アイコン -> プロジェクト アイコン -> デフォルトのGodot前面アイコン。

  • Adaptive Icon Background: 指定された背景アイコン -> デフォルトのGodot背景アイコン。

It's highly recommended to provide all the requested icons with their specified resolutions. This way, your application will look great on all Android devices and versions.

Google Playストア用にエクスポート

APKをGoogleのPlayストアにアップロードするには、デバッグ以外のキーストアファイルを使用して署名する必要があります。このようなファイルは次のように生成できます。

keytool -v -genkey -keystore mygame.keystore -alias mygame -keyalg RSA -validity 10000

このキーストアとキーは、開発者の身元を確認し、パスワードを記憶し、安全な場所に保管するために使用されます。GoogleのAndroidデベロッパー ガイドを使用して、APK 署名 の詳細をご覧ください。

次に、Android エクスポートプリセットで次のフォームに入力します:

../../_images/editor-export-presets-android.png
  • Release: 生成したばかりのキーストアファイルへのパスを入力します。

  • Release User: キーエイリアスで置き換えます。

  • Release Password: キーパスワード。現在、キーストアのパスワードとキーのパスワードは同じでなければならないことに注意してください。

Don't forget to uncheck the Export With Debug checkbox while exporting.

../../_images/export-with-debug-button.png

APKサイズの最適化

デフォルトでは、APKにはARMv7アーキテクチャとARMv8アーキテクチャの両方のネイティブライブラリが含まれます。これにより、サイズが大幅に増加します。より小さなAPKを作成するには、プロジェクトのAndroidエクスポートプリセットで Armeabi-v 7a または Arm 64 -v 8a のチェックを外します。これにより、単一のアーキテクチャのライブラリのみを含むAPKが作成されます。 ARMv7をターゲットとするアプリケーションはARMv8デバイスでも実行できますが、その逆は当てはまりません。

2019年8月以降、Google Playではすべてのアプリケーションを64ビット形式で利用可能である必要があります。これは、 ARMV7ライブラリ*のみ* を含むAPKはアップロードできないことを意味します。これを解決するには、Multiple APK support を使用して、いくつかのAPKをGoogle Playにアップロードできます。各APKは単一のアーキテクチャをターゲットにする必要があります。通常、ARMv7およびARMv8用のAPKを作成するだけで、現在使用されているほとんどのデバイスをカバーできます。

必要な機能のみを使用してAndroidエクスポートテンプレートをコンパイルすることにより、サイズをさらに最適化できます。詳細については、ビルドのサイズを最適化する を参照してください。

環境変数

You can use the following environment variables to set export options outside of the editor. During the export process, these override the values that you set in the export menu.

Android export environment variables

Export option

Environment variable

Encryption / Encryption Key

GODOT_SCRIPT_ENCRYPTION_KEY

Options / Keystore / Debug

GODOT_ANDROID_KEYSTORE_DEBUG_PATH

Options / Keystore / Debug User

GODOT_ANDROID_KEYSTORE_DEBUG_USER

Options / Keystore / Debug Password

GODOT_ANDROID_KEYSTORE_DEBUG_PASSWORD

Options / Keystore / Release

GODOT_ANDROID_KEYSTORE_RELEASE_PATH

Options / Keystore / Release User

GODOT_ANDROID_KEYSTORE_RELEASE_USER

Options / Keystore / Release Password

GODOT_ANDROID_KEYSTORE_RELEASE_PASSWORD