Download

srand link errors on Android 4.4 (ANR crash logs)

Maybe one for Chris, or someone else that has seen this before…

In the google play crash logs (published application, customer devices) I am seeing the following on (at least some) Android 4.4 devices.



java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "srand" referenced by "libUE4.so"...
	at java.lang.Runtime.loadLibrary(Runtime.java:364)
	at java.lang.System.loadLibrary(System.java:526)
	at com.epicgames.ue4.GameActivity.<clinit>(Unknown Source)
	at java.lang.Class.newInstanceImpl(Native Method)
	at java.lang.Class.newInstance(Class.java:1208)


I am compiling with (a customised source version of) UE4.11.2 and the following Android environment

  • MinSDKVersion=19
  • TargetSDKVersion=19
    Android NDK/SDK from Nvidia NVPack:
  • SDKDir=D:/NVPACK/android-sdk-windows
  • NDKDir=D:/NVPACK/android-ndk-r10e
  • AntDir=D:/NVPACK/apache-ant-1.8.2
  • JDKDir=C:/Program Files (x86)/Java/jdk1.7.0_55
  • SDK API Level=matchndk
  • NDK API Level=android-21

Unfortunately, I don’t actually have an Android 4.4 device on hand at the moment.
Will bumping NDK API Level down to 19 resolve this issue?
Is this a known/fixed issue in more recent UE4 versions (git commit link would be awesome).

More information:
There are some less than helpful comments on the following answer hub question
https://answers.unrealengine.com/questions/427472/javalangunsatisfiedlinkerror-andriod.html
I can compile and link locally just fine, this seems to be a runtime issue on some Android API levels.

A quick google reveals the same problem on stackoverflow and cocos2D with various suggestions around dropping API levels and running the 32bit edition of the Android NDK/SDK.

Little help!?

Change NDK API level to android-19. Android-21 NDK will not work on anything below Lollipop (5.0) since Google changed the libraries. Some functions like srand are not present in the libc.so on Android before 5.0 since previously they were inlined and are now functions.

Thanks Chris.

Sounds like I need to push out an update ASAP.
Guess a little more testing wouldn’t have been remiss before hitting that big shiny ‘publish’ button (there is a lesson to learn here kids)…