I have built an Android package for my project. It works properly on new mobile phones, but I encountered the issue mentioned in the title on an old mobile phone. How should I resolve this?
Crash Report
10-15 14:28:06.993 22262 22299 E AndroidRuntime: FATAL EXCEPTION: LoadLibraries
10-15 14:28:06.993 22262 22299 E AndroidRuntime: Process: <MyPackageName>, PID: 22262
10-15 14:28:06.993 22262 22299 E AndroidRuntime: java.lang.UnsatisfiedLinkError: Shared library "/system/lib64/libandroid.so" already opened by ClassLoader 0x0; can't open in ClassLoader 0x7ba4cbd96c
10-15 14:28:06.993 22262 22299 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
10-15 14:28:06.993 22262 22299 E AndroidRuntime: at java.lang.System.loadLibrary(System.java:1657)
10-15 14:28:06.993 22262 22299 E AndroidRuntime: at com.epicgames.unreal.GameApplication.LoadLibraries(GameApplication.java:139)
10-15 14:28:06.993 22262 22299 E AndroidRuntime: at com.epicgames.unreal.GameApplication$1.run(GameApplication.java:182)
10-15 14:28:06.993 22262 22299 E AndroidRuntime: at java.lang.Thread.run(Thread.java:764)
Software & Hardware Info
Unreal Version
5.6
Android Version
8.1.0 sdk:27
SOC
Qualcomm SDM660 SoC
OpenGL Version
ES 3.2
cell phone
vivo X20A
I noticed that there is a “System.loadLibrary(“android”);” in GameApplication.java. Maybe that’s the reason why it crashed. But I have no clue why it works fine in other phones and how can i fix it.
protected static void LoadLibraries(String CommandLine)
{
// We need to decide on enabling memory tracing before loading native code.
// ignore for now
try
{
System.loadLibrary("android");
...
}
catch (Exception e)
{
Log.debug(e.toString());
}
}
I have the exact same issue with Android 9 on my Samsung S8.
The app crashes on launch. Same log.
UE 5.6.1
SDK API installed 34-36.
Min SDK 26
Target SDK 35
NDK Android-26
Installed NDK SDK 29.0.14206865
Works on Samsung Fold 2 with Android 13.
ChatGPT suggest to check the plugins, which I will do now.
Since the file containing the System.loadLibrary(“android”) is in the intermediate folder and not in the engine template file, it must be generated by something else.
No plugin and no engine file containing the System.loadLibrary(“android”);
Same issue with a fresh project.
Migrated my project from 5.4.4 to 5.6.1 and updated android sdk, ndk and build tools.
Although I still don’t know why this issue occurs on some mobile phones, you can filter out the libAndroid.so file added by UE in the engine’s UEDeployAndroid.cs.
private void UpdateGameApplication(UnrealArch UnrealArch, string NDKArch, string EngineDir, string UnrealBuildPath,
bool bJavaPerfettoMarkers, UnrealTargetConfiguration Configuration, string SOName)
{
string SourceFilename = Path.Combine(EngineDir, "Build", "Android", "Java", "src", "com", "epicgames", "unreal", "GameApplication.java.template");
string DestFilename = Path.Combine(UnrealBuildPath, "src", "com", "epicgames", "unreal", "GameApplication.java");
string GameApplicationImportAdditionsDefault = "";
if (bJavaPerfettoMarkers)
{
GameApplicationImportAdditionsDefault += "import androidx.tracing.Trace;\n";
}
// add dependencies to early load during SplashActivity (optional)
List<string> UnrealDependencies = GetSODependencies(SOName, UnrealArch);
string GameApplicationEarlyLoad = "";
if (UnrealDependencies.Count > 0)
{
// Make sure these are first then release the lock
UnrealDependencies.Remove("GLESv3");
UnrealDependencies.Remove("EGL");
GameApplicationEarlyLoad += $"Trace.beginSection(\"GLESv3\");\n\t\t\tSystem.loadLibrary(\"GLESv3\");\nTrace.endSection();\n";
GameApplicationEarlyLoad += $"Trace.beginSection(\"EGL\");\n\t\t\tSystem.loadLibrary(\"EGL\");\nTrace.endSection();\n";
GameApplicationEarlyLoad += $"\t\t\tProcessSystemInfoLock.unlock();\n";
foreach (string SharedLibrary in UnrealDependencies)
{
GameApplicationEarlyLoad += $"Trace.beginSection(\"{SharedLibrary}\");\n\t\t\tSystem.loadLibrary(\"{SharedLibrary}\");\nTrace.endSection();\n";
}
In Last Foreach,I filtered out android as follow. After that, I can open my app on vivox20A and other phones. I assume that native libraries shouldn’t be open by apps which are already opened by the system. But I didn’t find the evidence to prove that. If anyone knows about it, please let me know(●’◡’●).