mit einem Klick
mobile-development
// Use when targeting Android/iOS — export and signing, permissions, plugins, in-app purchases, ads, app lifecycle, device features, and mobile performance
// Use when targeting Android/iOS — export and signing, permissions, plugins, in-app purchases, ads, app lifecycle, device features, and mobile performance
| name | mobile-development |
| description | Use when targeting Android/iOS — export and signing, permissions, plugins, in-app purchases, ads, app lifecycle, device features, and mobile performance |
Ship a Godot 4.x game to Android and iOS. This covers the platform-specific deltas beyond a generic export: signing, lifecycle, permissions, plugins, IAP, device features, and the mobile renderer/perf budget.
Related skills: export-pipeline for the generic export flow and CI/CD, responsive-ui for safe-area layout, input-handling for touch, godot-optimization for mobile performance, csharp-godot for C# mobile caveats.
Android: OpenJDK 17 and the Android SDK; set Java SDK Path + Android SDK Path in Editor Settings (per-user, not per-project). Generate a release keystore:
keytool -v -genkey -keystore mygame.keystore -alias mygame -keyalg RSA -validity 10000
Preset fields: Release / Release User / Release Password (keystore and key passwords must currently match); uncheck Export With Debug. AAB is mandatory for new Play uploads. CI env overrides: GODOT_ANDROID_KEYSTORE_RELEASE_{PATH,USER,PASSWORD}.
iOS: macOS + Xcode. Export needs an App Store Team ID + a reverse-DNS bundle Identifier; Godot generates an .xcodeproj you build from Xcode. The iOS simulator supports the Compatibility renderer only.
A custom Gradle build (Project → Install the Gradle Build template) is required for v2 plugins and IAP (Godot 4.2+).
Real Node notification constants: NOTIFICATION_APPLICATION_PAUSED (2015), NOTIFICATION_APPLICATION_RESUMED (2014), NOTIFICATION_APPLICATION_FOCUS_IN/_OUT (2016/2017), NOTIFICATION_WM_GO_BACK_REQUEST (1007, Android Back). There is no WM_CLOSE_REQUEST on mobile. Autosave on PAUSED; iOS gives ~5 s after pause to finish work before it kills the app.
func _notification(what: int) -> void:
match what:
NOTIFICATION_APPLICATION_PAUSED:
SaveManager.save_game() # App backgrounded — persist now.
NOTIFICATION_WM_GO_BACK_REQUEST:
_confirm_quit() # Android Back button.
The docs only show NotificationWMCloseRequest verbatim; these PascalCase names follow the same convention.
public override void _Notification(int what)
{
switch ((long)what)
{
case NotificationApplicationPaused:
SaveManager.SaveGame(); // App backgrounded — persist now.
break;
case NotificationWMGoBackRequest:
ConfirmQuit(); // Android Back button.
break;
}
}
Declare each permission in the export preset as permissions/<name>; request it at runtime with OS.request_permission(name). The result arrives via MainLoop's on_request_permissions_result(permission, granted). The permission must also be enabled in the preset, not just requested.
func _ready():
if "android.permission.POST_NOTIFICATIONS" not in OS.get_granted_permissions():
OS.request_permission("android.permission.POST_NOTIFICATIONS")
get_tree().on_request_permissions_result.connect(_on_perm_result)
func _on_perm_result(permission: String, granted: bool):
print("%s granted: %s" % [permission, granted])
public override void _Ready()
{
if (!OS.GetGrantedPermissions().Contains("android.permission.POST_NOTIFICATIONS"))
OS.RequestPermission("android.permission.POST_NOTIFICATIONS");
GetTree().OnRequestPermissionsResult += OnPermResult;
}
private void OnPermResult(string permission, bool granted)
=> GD.Print($"{permission} granted: {granted}");
Godot 4.4+ only. JavaClassWrapper.wrap("<java.class>") calls Java/Kotlin classes with no plugin; the AndroidRuntime singleton (Engine.get_singleton("AndroidRuntime")) exposes getActivity(), getApplicationContext(), and createRunnableFromGodotCallable(callable).
The simpler cross-platform alternative needs no 4.4: Input.vibrate_handheld(duration_ms, amplitude) (requires the VIBRATE permission; iOS needs iOS 13+). See Plugins for the full JavaClassWrapper/AndroidRuntime API, Toast/Intent recipes, and inner-class syntax.
# Godot 4.4+ — requires the VIBRATE permission in the export preset.
func vibrate_ms(duration_ms: int) -> void:
if Engine.has_singleton("AndroidRuntime"):
var runtime := Engine.get_singleton("AndroidRuntime")
var context := runtime.getApplicationContext()
var vibrator := context.getSystemService("vibrator")
if vibrator.hasVibrator():
var Effect = JavaClassWrapper.wrap("android.os.VibrationEffect")
var effect = Effect.createOneShot(duration_ms, Effect.DEFAULT_AMPLITUDE)
vibrator.vibrate(effect)
The docs are GDScript-only here; the exact C# Variant-marshaling chain (.AsGodotObject() on each Java return) is untested against a device — verify on a real 4.4+ Android build.
// Godot 4.4+ — requires the VIBRATE permission in the export preset.
public void VibrateMs(int durationMs)
{
if (!Engine.HasSingleton("AndroidRuntime")) return;
var runtime = Engine.GetSingleton("AndroidRuntime");
var context = runtime.Call("getApplicationContext").AsGodotObject();
var vibrator = context.Call("getSystemService", "vibrator").AsGodotObject();
if (vibrator.Call("hasVibrator").AsBool())
{
var effect = JavaClassWrapper.Wrap("android.os.VibrationEffect");
var oneShot = effect.Call("createOneShot", durationMs, effect.Get("DEFAULT_AMPLITUDE"));
vibrator.Call("vibrate", oneShot);
}
}
DisplayServer.get_display_safe_area() -> Rect2i (Android/iOS) returns the usable region inside notches/cutouts; get_display_cutouts() (Android) lists the cutout rects. Motion sensors live on Input (get_accelerometer/gravity/gyroscope/magnetometer, returning Vector3, Android/iOS only).
func _ready():
var safe := DisplayServer.get_display_safe_area() # Rect2i
$UI.position = safe.position
$UI.size = safe.size
public override void _Ready()
{
Rect2I safe = DisplayServer.GetDisplaySafeArea();
var ui = GetNode<Control>("UI");
ui.Position = safe.Position;
ui.Size = safe.Size;
}
Use the Mobile (or Compatibility) renderer; the iOS simulator is Compatibility-only. Enable rendering/textures/vram_compression/import_etc2_astc = true (ETC2/ASTC) for Android texture compression. Keep single-arch APKs small; AABs split per-device automatically. Defer deep draw-call/batching tuning to godot-optimization.
C# Android/iOS export is Godot 4.2+ but experimental. Android C# export requires .NET 9+ (with Godot 4.5); iOS export only from macOS, and the simulator templates are x64-only. C# cannot export to Web. Test the C# export pipeline early — it is the riskiest part of a C# mobile project.
Deeper: Plugins (Android v2 / iOS) · In-app purchases & ads · Crash debugging
NOTIFICATION_APPLICATION_PAUSED (iOS ~5 s budget respected)get_display_safe_area(); notch/cutout handledUse when building native extensions for Godot — godot-cpp (C++) or gdext (Rust), binding classes, building, and GDScript/C# interop
Use when running work off the main thread — WorkerThreadPool, Thread/Mutex/Semaphore, call_deferred, thread-safe scene access, and threaded resource loading
Use when importing and managing assets — image compression, 3D scene import, audio formats, resource formats, and import configuration
Use when working with C# in Godot — conventions, GodotSharp API differences from GDScript, project setup, and interop
Use when exporting and distributing Godot games — export presets, platform settings, CI/CD with GitHub Actions
Use when optimizing Godot games — profiler, draw calls, physics tuning, memory management, and common bottlenecks