godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
86.66k stars 19.36k forks source link

Android export on Google Play crash report: `UnsatisfiedLinkError` for `libgodot_android.so` #59128

Open wangdong20 opened 2 years ago

wangdong20 commented 2 years ago

Godot version

3.4.3

System information

MacOS 12.1, Mac Pro, GLES2

Issue description

I just released game on Google play which is exported from Godot. In order to support low end device, I choose to support GLES2. It does work on my Android phone and passes the alpha test on Google play console but got crashes from Google play console statistics. Here is the crash log and device information:

java.lang.UnsatisfiedLinkError: 
  at java.lang.Runtime.loadLibrary0 (Runtime.java:1067)
  at java.lang.Runtime.loadLibrary0 (Runtime.java:1007)
  at java.lang.System.loadLibrary (System.java:1667)
  at org.godotengine.godot.GodotLib.<clinit> (GodotLib.java:45)
  at org.godotengine.godot.Godot.initializeGodot (Godot.java:563)
  at org.godotengine.godot.Godot.onCreate (Godot.java:716)
  at androidx.fragment.app.Fragment.performCreate (Fragment.java:2949)
  at androidx.fragment.app.FragmentStateManager.create (FragmentStateManager.java:475)
  at androidx.fragment.app.FragmentStateManager.moveToExpectedState (FragmentStateManager.java:278)
  at androidx.fragment.app.FragmentManager.executeOpsTogether (FragmentManager.java:2189)
  at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute (FragmentManager.java:2100)
  at androidx.fragment.app.FragmentManager.execSingleAction (FragmentManager.java:1971)
  at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss (BackStackRecord.java:311)
  at org.godotengine.godot.FullScreenGodotApp.onCreate (FullScreenGodotApp.java:72)
  at com.godot.game.GodotApp.onCreate (GodotApp.java:45)

Device infos: Lenovo Tab M10 (HD), TB-X505X ABI: arm64-v8a, armeabi-v7a, armeabi Device size: 800x1280 DPI: 160 (mdpi) Android version: API28, API 29 OpenGL ES version: 3.2 GPU: Qualcomm Adreno 504 (320 Mhz)

Steps to reproduce

Export as aab from Godot support GLES2. Upload to Google play store. Get crash log on the Google play console.

Minimal reproduction project

No response

akien-mga commented 2 years ago
java.lang.UnsatisfiedLinkError: 
  at java.lang.Runtime.loadLibrary0 (Runtime.java:1067)
  at java.lang.Runtime.loadLibrary0 (Runtime.java:1007)
  at java.lang.System.loadLibrary (System.java:1667)
  at org.godotengine.godot.GodotLib.<clinit> (GodotLib.java:45)
  at org.godotengine.godot.Godot.initializeGodot (Godot.java:563)
  at org.godotengine.godot.Godot.onCreate (Godot.java:716)

It seems to fail loading libgodot_android.so here: https://github.com/godotengine/godot/blob/0ae6150d8eed297497544c007405720c7307792a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java#L44-L46

Can you check that your AAB properly contains the libgodot_android.so library for all the ABIs that you support?

ABI: arm64-v8a, armeabi-v7a, armeabi

Seems like armeabi is still reported as a supported secondary ABI even though it's no longer supported by Google Play: https://developer.android.com/ndk/guides/abis

I wonder if for some reason this device would wrongly attempt to load the armeabi library (which we don't provide, and can't even build anymore) instead of arm64-v8a?

wangdong20 commented 2 years ago
java.lang.UnsatisfiedLinkError: 
  at java.lang.Runtime.loadLibrary0 (Runtime.java:1067)
  at java.lang.Runtime.loadLibrary0 (Runtime.java:1007)
  at java.lang.System.loadLibrary (System.java:1667)
  at org.godotengine.godot.GodotLib.<clinit> (GodotLib.java:45)
  at org.godotengine.godot.Godot.initializeGodot (Godot.java:563)
  at org.godotengine.godot.Godot.onCreate (Godot.java:716)

It seems to fail loading libgodot_android.so here:

https://github.com/godotengine/godot/blob/0ae6150d8eed297497544c007405720c7307792a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java#L44-L46

Can you check that your AAB properly contains the libgodot_android.so library for all the ABIs that you support?

ABI: arm64-v8a, armeabi-v7a, armeabi

Seems like armeabi is still reported as a supported secondary ABI even though it's no longer supported by Google Play: https://developer.android.com/ndk/guides/abis

I wonder if for some reason this device would wrongly attempt to load the armeabi library (which we don't provide, and can't even build anymore) instead of arm64-v8a?

How can I check the AAB properly contains the libgodot_android.so library for all the ABIs that I support?

I just set the arm64-v8a, armeabi-v7a true on Godot android export setting.

akien-mga commented 2 years ago

Another user (Dan_SCE) reported the same issue last week on the contributors chat: image image

@wangdong20 Do you do a custom build with additional plugins?


I'm not familiar with Java and Android lib loading but it's worth noting that UnsatisfiedLinkError may also mean that even though libgodot_android.so is present, one of its dependencies cannot be loaded (and then libgodot_android.so cannot be loaded either). I.e. this may not be a "file not found" error but an actual dependency issue.

Here are the dependencies for lib/arm64-v8a/libgodot_android.so in 3.4.3:

 0x0000000000000001 (NEEDED)             Shared library: [libc++_shared.so]
 0x0000000000000001 (NEEDED)             Shared library: [libOpenSLES.so]
 0x0000000000000001 (NEEDED)             Shared library: [libEGL.so]
 0x0000000000000001 (NEEDED)             Shared library: [libGLESv3.so]
 0x0000000000000001 (NEEDED)             Shared library: [libGLESv2.so]
 0x0000000000000001 (NEEDED)             Shared library: [libandroid.so]
 0x0000000000000001 (NEEDED)             Shared library: [liblog.so]
 0x0000000000000001 (NEEDED)             Shared library: [libz.so]
 0x0000000000000001 (NEEDED)             Shared library: [libdl.so]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so]

(Found with <android-ndk>/21.4.7075529/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-readelf -d lib/arm64-v8a/libgodot_android.so)

Which are the ones we set there: https://github.com/godotengine/godot/blob/0ae6150d8eed297497544c007405720c7307792a/platform/android/detect.py#L362

Worth noting, libGLESv3.so as a hard dependency might seem weird, but AFAIR it's provided as a stub on all Android devices even if OpenGL ES 3.0 is not supported.


How can I check the AAB properly contains the libgodot_android.so library for all the ABIs that I support?

You can unzip the generated AAB and inspect the contents to see if both libgodot_android.so and libc++_shared.so are present in the lib/<abi>/ folders.

wangdong20 commented 2 years ago

I made a custom build with admob plugin.

Just unziped the AAB file and both libgodot_android.so and libc++_shared.so are presented in the lib/<abi>/ folders.

DmitriySalnikov commented 2 years ago

Same issue:

java.lang.UnsatisfiedLinkError: 
  at java.lang.Runtime.loadLibrary0 (Runtime.java:1087)
  at java.lang.Runtime.loadLibrary0 (Runtime.java:1008)
  at java.lang.System.loadLibrary (System.java:1664)
  at org.godotengine.godot.GodotLib.<clinit> (GodotLib.java:45)
  at org.godotengine.godot.Godot.initializeGodot (Godot.java:563)
  at org.godotengine.godot.Godot.onCreate (Godot.java:716)
  at androidx.fragment.app.Fragment.performCreate (Fragment.java:2949)
  at androidx.fragment.app.FragmentStateManager.create (FragmentStateManager.java:475)
  at androidx.fragment.app.FragmentStateManager.moveToExpectedState (FragmentStateManager.java:278)
  at androidx.fragment.app.FragmentManager.executeOpsTogether (FragmentManager.java:2189)
  at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute (FragmentManager.java:2100)
  at androidx.fragment.app.FragmentManager.execSingleAction (FragmentManager.java:1971)
  at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss (BackStackRecord.java:311)
  at org.godotengine.godot.FullScreenGodotApp.onCreate (FullScreenGodotApp.java:72)
  at com.godot.game.GodotApp.onCreate (GodotApp.java:45)
  at android.app.Activity.performCreate (Activity.java:8215)
  at android.app.Activity.performCreate (Activity.java:8199)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1309)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3824)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:4027)
  at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:85)
  at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:135)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2336)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:247)
  at android.app.ActivityThread.main (ActivityThread.java:8676)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)

Samsung Galaxy Tab A7 ABI: arm64-v8a armeabi-v7a armeabi Device size: 1200x2000 DPI: 240 (hdpi) Android version: Android 10 (SDK 29), Android 11 (SDK 30), Android 12 (SDK 31) OpenGL ES version: 3.2 System on Chip (SOC): Qualcomm SM6115 GPU: Qualcomm Adreno 610 (950 MHz)

Godot: v3.4.4.stable.custom_build [419e713a2] All 4 ABIs are included


And only after I wrote everything above, I noticed that the error report came from a version downloaded from a third-party resource, not from Google play... And now I do not know how reliable this report is at all.

image

KYRYAMBA commented 1 year ago

one year later 3.5.1 project target SDK 32 uses custom build and custom export template with encryption key. on my testing devices works good..

google crosshatch (Pixel 3 XL) Android 12 (SDK 31) both lib// contains libc++_shared.so and libgodot_android.so

java.lang.UnsatisfiedLinkError Exception java.lang.UnsatisfiedLinkError: dlopen failed: library "libgodot_android.so" not found at java.lang.Runtime.loadLibrary0 (Runtime.java:1077) at java.lang.Runtime.loadLibrary0 (Runtime.java:998) at java.lang.System.loadLibrary (System.java:1661) at org.godotengine.godot.GodotLib. (GodotLib.java:49) at org.godotengine.godot.Godot.initializeGodot (Godot.java:587) at org.godotengine.godot.Godot.onCreate (Godot.java:723) at androidx.fragment.app.Fragment.performCreate (Fragment.java:2949) at androidx.fragment.app.FragmentStateManager.create (FragmentStateManager.java:475) at androidx.fragment.app.FragmentStateManager.moveToExpectedState (FragmentStateManager.java:278) at androidx.fragment.app.FragmentManager.executeOpsTogether (FragmentManager.java:2189) at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute (FragmentManager.java:2100) at androidx.fragment.app.FragmentManager.execSingleAction (FragmentManager.java:1971) at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss (BackStackRecord.java:311) at org.godotengine.godot.FullScreenGodotApp.onCreate (FullScreenGodotApp.java:69) at com.godot.game.GodotApp.onCreate (GodotApp.java:45) at android.app.Activity.performCreate (Activity.java:8051) at android.app.Activity.performCreate (Activity.java:8031) at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1329) at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3612) at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3796) at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:103) at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2214) at android.os.Handler.dispatchMessage (Handler.java:106) at android.os.Looper.loopOnce (Looper.java:201) at android.os.Looper.loop (Looper.java:288) at android.app.ActivityThread.main (ActivityThread.java:7842) at java.lang.reflect.Method.invoke at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1003)