From ca46bafc51919a2ea5c41b1d474e658a1d01d8ce Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio Date: Wed, 6 May 2026 12:51:42 -0700 Subject: [PATCH] Fix the command line parsing logic for the `--main-pack` argument --- .../java/lib/src/main/java/org/godotengine/godot/Godot.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/android/java/lib/src/main/java/org/godotengine/godot/Godot.kt b/platform/android/java/lib/src/main/java/org/godotengine/godot/Godot.kt index a34f22baff0..a932a81cc54 100644 --- a/platform/android/java/lib/src/main/java/org/godotengine/godot/Godot.kt +++ b/platform/android/java/lib/src/main/java/org/godotengine/godot/Godot.kt @@ -284,8 +284,9 @@ class Godot private constructor(val context: Context) { } else if (commandLine[i] == "--fullscreen") { useImmersive.set(true) newArgs.add(commandLine[i]) - } else if (commandLine[i] == "--background_color") { + } else if (hasExtra && commandLine[i] == "--background_color") { setWindowColor(commandLine[i + 1]) + i++ } else if (commandLine[i] == "--disable_godot_splash") { disableGodotSplash = true } else if (commandLine[i] == "--benchmark") { @@ -301,13 +302,17 @@ class Godot private constructor(val context: Context) { i++ } else if (hasExtra && commandLine[i] == "--main-pack") { + newArgs.add(commandLine[i]) + val mainPackPath = commandLine[i + 1] + newArgs.add(commandLine[i + 1]) // Check the storage scope of the main pack path. For template builds, `useApkExpansion` is enabled // if the storage scope is APP. val storageScope = fileAccessHandler.storageScopeIdentifier.identifyStorageScope(mainPackPath) if (isTemplateBuild()) { useApkExpansion = storageScope == StorageScope.APP } + i++ } else if (commandLine[i].trim().isNotEmpty()) { // This block should always be last! newArgs.add(commandLine[i]) } @@ -329,6 +334,7 @@ class Godot private constructor(val context: Context) { } if (nativeLayerInitializeCompleted && !nativeLayerSetupCompleted) { + Log.v(TAG, "Setting up native layer with params: $commandLine") nativeLayerSetupCompleted = GodotLib.setup(commandLine.toTypedArray(), tts) if (!nativeLayerSetupCompleted) { throw IllegalStateException("Unable to setup the Godot engine! Aborting...")