Exportación para Android

Exportar para Android tiene menos requisitos que compilar Godot para él. Los siguientes pasos detallan lo que se necesita para configurar el SDK y el motor.

Descargar el SDK de Android

Download and install the Android SDK from developer.android.com.

If you install Android Studio, you need to run it once to complete the SDK setup.

Instalar OpenJDK u Oracle JDK

Descarga e instala OpenJDK u Oracle JDK. Es posible que las versiones inferiores a JDK 8 no funcionen, algunos usuarios han informado de problemas con el jarsigner (utilizado para firmar los APK) en JDK 7.

If you install OpenJDK, choose 1.8. Don’t choose the openjdk-jre files as that only contains the JRE, not the JDK which is required here.

Crear un debug.keystore

Android necesita un archivo de almacenamiento de claves de depuración para instalarlo en dispositivos y distribuir APKs no liberados. Si has usado el SDK antes y has construido proyectos, ant o eclipse probablemente generó uno para ti (en Linux y macOS, puedes encontrarlo en el directorio ~/.android).

If you can’t find it or need to generate one, the keytool command from the JDK can be used for this purpose:

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

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.

Asegúrate de que tienes adb

Android Debug Bridge (adb) is the command line tool used to communicate with Android devices. It’s installed with the SDK, but you may need to install one (any) of the Android API levels for it to be installed in the SDK directory.

Instalándolo en Godot

Acceda a la pantalla Ajustes del editor. Esta pantalla contiene la configuración del editor para la cuenta de usuario en la computadora (Es independiente del proyecto).

../../../_images/editorsettings.png

Desplázate hacia abajo hasta la sección donde se encuentra la configuración de Android:

../../../_images/androidsdk.png

En esta pantalla, se debe establecer la ruta a 3 archivos:

  • The adb executable (adb.exe on Windows) - It can usually be found at %LOCALAPPDATA%\Android\Sdk\platform-tools\adb.exe.
  • The jarsigner executable (from JDK 6 or 8) - On Windows, OpenJDK installs to a dir like %PROGRAMFILES%\ojdkbuild\java-1.8.0-openjdk-1.8.0.232-2\bin. The exact path may vary depending on the OpenJDK update you’ve installed.
  • The debug .keystore file - It can be found in the folder where you put the debug.keystore file you created above.

Una vez configurado ¡todo está listo para exportar a Android!

Providing launcher icons

Launcher icons are used by Android launcher apps to represent your application to users. Godot only requires high-resolution icons (for xxxhdpi density screens) and will automatically generate lower-resolution variants.

There are two types of icons required by Godot:

  • 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: Starting from Android 8 (inclusive), Adaptive Icons were introduced. Applications will need to include separate background and foreground icons to have a native look. The user’s launcher application will control the icon’s animation and masking. Must be at least 432×432 px.

Ver también

It’s important to adhere to some rules when designing adaptive icons. Google Design has provided a nice article that helps to understand those rules and some of the capabilities of adaptive icons.

Prudencia

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

If you don’t provide some of the requested icons, Godot will replace them using a fallback chain, trying the next in line when the current one fails:

  • Main Icon: Provided main icon -> Project icon -> Default Godot main icon.
  • Adaptive Icon Foreground: Provided foreground icon -> Provided main icon -> Project icon -> Default Godot foreground icon.
  • Adaptive Icon Background: Provided background icon -> Default Godot background icon.

It’s highly recommended to provide all of the requested icons, and at least with the specified resolutions. Only this way your application will look great on all the Android devices and versions.

Exportar para la Google Play Store

Subir un APK a Google Play Store requiere que sea firmado usando un archivo keystore non-debug, el cual puede generarse así:

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

Este keystore y su clave se utilizan para verificar la identidad de su desarrollador, recuerda la contraseña y guárdala en un lugar seguro. Utiliza las guías de Google para desarrolladores de Android para obtener más información sobre APK signing.

Ahora rellena los siguientes formularios en tus opciones predeterminadas de exportación Android:

../../../_images/editor-export-presets-android.png
  • Release: Enter the path to the keystore file you just generated.
  • Release User: Replace with the key alias.
  • Release Password: Key password. Note that the keystore password and the key password currently have to be the same.

Your export_presets.cfg file now contains sensitive information. If you use a version control system, you should remove it from public repositories and add it to your .gitignore file or equivalent.

Don’t forget to uncheck the Export With Debug checkbox while choosing the APK’s name.

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

Optimizing the APK size

By default, the APK will contain native libraries for both ARMv7 and ARMv8 architectures. This increases its size significantly. To create a smaller APK, uncheck either Armeabi-v 7a or Arm 64 -v 8a in your project’s Android export preset. This will create an APK that only contains a library for a single architecture. Note that applications targeting ARMv7 can also run on ARMv8 devices, but the opposite is not true.

Since August 2019, Google Play requires all applications to be available in 64-bit form. This means you cannot upload an APK that contains just an ARMv7 library. To solve this, you can upload several APKs to Google Play using its Multiple APK support. Each APK should target a single architecture; creating an APK for ARMv7 and ARMv8 is usually sufficient to cover most devices in use today.

You can optimize the size further by compiling an Android export template with only the features you need. See Optimizing a build for size for more information.