Skip to content

Commit 2d41859

Browse files
Fix startup crash by handling native library load failure
Wraps the `Java.Lang.JavaSystem.LoadLibrary("osu.Android.Native")` call in `OsuGameActivity` with a try-catch block. This prevents the application from crashing on startup if the native library cannot be loaded (e.g., due to missing dependencies, architecture mismatch, or device incompatibility). Since the native library is currently only used for optional features (Vulkan, Oboe) which are disabled by default, this allows the game to function normally without them. Logs the failure to Android Logcat for debugging purposes.
1 parent 9c7d4d1 commit 2d41859

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
"rollForward": "latestFeature",
55
"allowPrerelease": false
66
}
7-
}
7+
}

osu.Android/OsuGameActivity.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,14 @@ protected override void OnCreate(global::Android.OS.Bundle? savedInstanceState)
145145
{
146146
base.OnCreate(savedInstanceState);
147147

148-
global::Java.Lang.JavaSystem.LoadLibrary("osu.Android.Native");
148+
try
149+
{
150+
global::Java.Lang.JavaSystem.LoadLibrary("osu.Android.Native");
151+
}
152+
catch (Exception e)
153+
{
154+
global::Android.Util.Log.Error("OsuGameActivity", $"Failed to load native library: {e}");
155+
}
149156

150157
// OnNewIntent() only fires for an activity if it's *re-launched* while it's on top of the activity stack.
151158
// on first launch we still have to fire manually.

0 commit comments

Comments
 (0)