Android Release: "libaws-cpp-sdk-gamelift.so" not found

Hi folks,

In my ongoing quest to get a Release build on Android I am now running into an issue where the “libaws-cpp-sdk-gamelift.so” lib is not found in the APK. It’s copied into \dev\BinAndroidClang.Release, but it doesn’t make it into the final APK that’s installed on device.

11-27 12:39:36.397 907 1438 I ActivityManager: Start proc 24198:com.company.mygame/u0a341 for activity com.company.mygame/.mygameActivity
11-27 12:39:36.474 24198 24198 D LMBR : BootStrap: Starting Library load
11-27 12:39:36.500 24198 24198 D AndroidRuntime: Shutting down VM
11-27 12:39:36.503 24198 24198 E AndroidRuntime: FATAL EXCEPTION: main
11-27 12:39:36.503 24198 24198 E AndroidRuntime: Process: com.company.mygame, PID: 24198
11-27 12:39:36.503 24198 24198 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libaws-cpp-sdk-gamelift.so" not found
11-27 12:39:36.503 24198 24198 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
11-27 12:39:36.503 24198 24198 E AndroidRuntime: at java.lang.System.loadLibrary(System.java:1657)
11-27 12:39:36.503 24198 24198 E AndroidRuntime: at com.company.mygame.mygameActivity.<clinit>(Unknown Source:14)
11-27 12:39:36.503 24198 24198 E AndroidRuntime: at java.lang.Class.newInstance(Native Method)
11-27 12:39:36.503 24198 24198 E AndroidRuntime: at android.app.Instrumentation.newActivity(Instrumentation.java:1173)
11-27 12:39:36.503 24198 24198 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708)
11-27 12:39:36.503 24198 24198 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
11-27 12:39:36.503 24198 24198 E AndroidRuntime: at android.app.ActivityThread.-wrap11(Unknown Source:0)
11-27 12:39:36.503 24198 24198 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
11-27 12:39:36.503 24198 24198 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:105)
11-27 12:39:36.503 24198 24198 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)
11-27 12:39:36.503 24198 24198 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6541)
11-27 12:39:36.503 24198 24198 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
11-27 12:39:36.503 24198 24198 E AndroidRuntime: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
11-27 12:39:36.503 24198 24198 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
11-27 12:39:36.507 907 1438 W ActivityManager: Force finishing activity com.company.mygame/.mygameActivity
11-27 12:39:36.512 907 942 I ActivityManager: Showing crash dialog for package com.company.mygame u0

Any ideas? @Scott@AGS? :slight_smile:

Hi @Twolewis,

This is likely due to the strict handling of release builds being monolithic, so it’s a bit odd the shared version of GameLift is getting included in the build. I’ll need to do some further investigation as to why that’s happening.

Meanwhile, the shared library not getting copied into the APK can easily be patched by modifying the following in Tools/build/waf-1.7.13/lmbrwaflib/android.py.

Original:

    @feature('c', 'cxx', 'copy_3rd_party_binaries')
@after_method('apply_link')
def add_3rd_party_library_stripping(self):
"""
Strip and copy 3rd party shared libraries so they are included into the APK.
"""
if 'android' not in self.env['PLATFORM'] or self.bld.spec_monolithic_build():
return

Patched:

    @feature('c', 'cxx', 'copy_3rd_party_binaries')
@after_method('apply_link')
def add_3rd_party_library_stripping(self):
"""
Strip and copy 3rd party shared libraries so they are included into the APK.
"""
if 'android' not in self.env['PLATFORM']:
return

Hi @Scott@AGS -

That got rid of the gamelift lib, but now has moved on to looking for “libaws-cpp-sdk-core.so”:

11-27 16:52:07.174 12287 12287 E AndroidRuntime: FATAL EXCEPTION: main
11-27 16:52:07.174 12287 12287 E AndroidRuntime: Process: com.company.mygame, PID: 12287
11-27 16:52:07.174 12287 12287 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libaws-cpp-sdk-core.so" not found
11-27 16:52:07.174 12287 12287 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
11-27 16:52:07.174 12287 12287 E AndroidRuntime: at java.lang.System.loadLibrary(System.java:1657)
11-27 16:52:07.174 12287 12287 E AndroidRuntime: at com.company.mygame.mygameActivity.<clinit>(Unknown Source:14)
11-27 16:52:07.174 12287 12287 E AndroidRuntime: at java.lang.Class.newInstance(Native Method)
11-27 16:52:07.174 12287 12287 E AndroidRuntime: at android.app.Instrumentation.newActivity(Instrumentation.java:1173)
11-27 16:52:07.174 12287 12287 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708)
11-27 16:52:07.174 12287 12287 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
11-27 16:52:07.174 12287 12287 E AndroidRuntime: at android.app.ActivityThread.-wrap11(Unknown Source:0)
11-27 16:52:07.174 12287 12287 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
11-27 16:52:07.174 12287 12287 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:105)
11-27 16:52:07.174 12287 12287 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)
11-27 16:52:07.174 12287 12287 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6541)
11-27 16:52:07.174 12287 12287 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
11-27 16:52:07.174 12287 12287 E AndroidRuntime: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
11-27 16:52:07.174 12287 12287 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
11-27 16:52:07.176 907 2324 W ActivityManager: Force finishing activity com.company.mygame/.mygameActivity

Hi @Twolewis, I was cautiously optimistic that was going patch the issue but had a feeling it was only going to push the problem further down the chain :frowning:

Do you happen to have “AWS_CPP_SDK_GAMELIFT_SHARED” as a use or uselib in any of your wscripts? If so, the “_SHARED” suffix should be removed. I don’t see anything else that would be causing the shared version of GameLift to be included instead of the static in release.

Hiya @Scott@AGS -

The only _SHARED I have is for Windows dedicated - AWS_GAMELIFT_SERVER_SHARED.

For everything else I specify AWS_CPP_SDK_GAMELIFT.

Snippet from my wscript file with the uselibs:


uselib = ['AWS_CPP_SDK_CORE', 'AWS_CPP_SDK_LAMBDA', 'AWS_CPP_SDK_GAMELIFT'],
win_debug_dedicated_uselib = ['AWS_GAMELIFT_SERVER_SHARED'],
win_profile_dedicated_uselib = ['AWS_GAMELIFT_SERVER_SHARED'],
win_performance_dedicated_uselib = ['AWS_GAMELIFT_SERVER_STATIC'],
win_release_dedicated_uselib = ['AWS_GAMELIFT_SERVER_STATIC'],

Hi @Scott@AGS -

Here you go:

monolithic_uselibs: CryInput.uselib = []
monolithic_uselibs: Cry3DEngine.uselib = []
monolithic_uselibs: CrySoundSystem.uselib = []
monolithic_uselibs: CryAudioImplNoSound.uselib = []
monolithic_uselibs: CryAudioImplWwise.uselib = ['WWISE']
monolithic_uselibs: CryAction.uselib = ['OPENSSL']
monolithic_uselibs: CryAISystem.uselib = []
monolithic_uselibs: CryAnimation.uselib = []
monolithic_uselibs: CryEntitySystem.uselib = []
monolithic_uselibs: CryFont.uselib = ['FREETYPE2']
monolithic_uselibs: CryNetwork.uselib = []
monolithic_uselibs: CryPhysics.uselib = []
monolithic_uselibs: CryScriptSystem.uselib = []
monolithic_uselibs: CrySystem.uselib = ['LZ4', 'TIFF', 'TOMCRYPT', 'TOMMATH', 'EXPAT', 'ZLIB', 'MD5']
monolithic_uselibs: CryRenderGL.uselib = ['LZMA', 'LZSS', 'LZ4']
monolithic_uselibs: SDL2_Android.uselib = []
monolithic_uselibs: GemRegistry.uselib = []
monolithic_uselibs: SDL2Ext.uselib = []
[WARNING] 'libpath' value 'c:\Amazon\Lumberyard\1.11.1.0\dev\Code\SDKs\LibTomCrypt\lib\ios' defined in TaskGenerator "MyGameIOSLauncher" does not exist
[WARNING] 'libpath' value 'c:\Amazon\Lumberyard\1.11.1.0\dev\Code\SDKs\LibTomMath\lib\ios' defined in TaskGenerator "MyGameIOSLauncher" does not exist
[WARNING] 'libpath' value 'c:\Amazon\Lumberyard\1.11.1.0\dev\Code\SDKs\FreeType2\ios\lib' defined in TaskGenerator "MyGameIOSLauncher" does not exist
monolithic_uselibs: EMotionFX.uselib = []
monolithic_uselibs: MyGame.uselib = ['AWS_CPP_SDK_CORE', 'AWS_CPP_SDK_LAMBDA', 'AWS_CPP_SDK_GAMELIFT']
monolithic_uselibs: LyShine.uselib = []
monolithic_uselibs: CloudCanvasCommon.uselib = ['AWS_CPP_SDK_CORE', 'OPENSSL']
monolithic_uselibs: LegacyGameInterface.uselib = []
monolithic_uselibs: CryLegacy.uselib = []
monolithic_uselibs: Maestro.uselib = []
monolithic_uselibs: CertificateManager.uselib = []
monolithic_uselibs: CloudGemFramework.uselib = ['AWS_CPP_SDK_COGNITO_IDENTITY', 'AWS_CPP_SDK_IDENTITY_MANAGEMENT', 'AWS_CPP_SDK_LAMBDA', 'AWS_CPP_SDK_CORE']
monolithic_uselibs: GameLift.uselib = []
monolithic_uselibs: Camera.uselib = []
monolithic_uselibs: LmbrCentral.uselib = []

With your changes from earlier in the thread, it’s no longer looking for the gamelift .so in the package, but is instead looking for ‘libaws-cpp-sdk-core.so’ … not sure how they are related? Should I not be specifying AWS_CPP_SDK_CORE in my uselibs?

Hi @Twolewis,

Hmmm, let’s try and pinpoint where it’s sneaking into the build. Can you add the following to the function “MonolithicBuildModule” in Tools/build/waf-1.7.13/lmbrwaflib/cryengine_modules.py and run your build command with “–zones=monolithic_uselibs”.

        if 'uselib' in kw:
Logs.debug('monolithic_uselibs: %s.uselib = %s', kw['target'], kw['uselib'])

This will at least tell us what 3rd party libs each module is pulling into the build.

Hi @Scott@AGS - any ideas yet? :confused:

Heya @Scott@AGS

That checks out it seems :confused:

	Line 329: LIB_AWS_CPP_SDK_GAMELIFT_SHARED = ['aws-cpp-sdk-gamelift']
Line 330: LIB_AWS_CPP_SDK_GAMELIFT_SHARED_ANDROID_21 = ['aws-cpp-sdk-gamelift']
Line 406: SHAREDLIB_AWS_CPP_SDK_GAMELIFT_SHARED = ['libaws-cpp-sdk-gamelift.so']
Line 407: SHAREDLIB_AWS_CPP_SDK_GAMELIFT_SHARED_ANDROID_21 = ['libaws-cpp-sdk-gamelift.so']
Line 518: STLIB_AWS_CPP_SDK_GAMELIFT = ['aws-cpp-sdk-gamelift']
Line 519: STLIB_AWS_CPP_SDK_GAMELIFT_ANDROID_21 = ['aws-cpp-sdk-gamelift']
Line 520: STLIB_AWS_CPP_SDK_GAMELIFT_STATIC = ['aws-cpp-sdk-gamelift']
Line 521: STLIB_AWS_CPP_SDK_GAMELIFT_STATIC_ANDROID_21 = ['aws-cpp-sdk-gamelift']

Hi @Twolewis, Unfortunately since I’m not able to reproduce this issue locally I’m running out of ideas. The information you’ve provided shows no evidence of how the GameLift shared library is getting included in the build and yet it’s still there :frowning:

This is kind of a last ditch effort here but check to see if the release build cache is corrupt. Navigate to BinTemp/c4che/android_armv7_clang_release_cache.py and search for the substring ‘LIB_AWS_CPP_SDK_GAMELIFT’. You should only find the following entries:

  • LIB_AWS_CPP_SDK_GAMELIFT_SHARED
  • LIB_AWS_CPP_SDK_GAMELIFT_SHARED_ANDROID_21
  • SHAREDLIB_AWS_CPP_SDK_GAMELIFT_SHARED
  • SHAREDLIB_AWS_CPP_SDK_GAMELIFT_SHARED_ANDROID_21
  • STLIB_AWS_CPP_SDK_GAMELIFT
  • STLIB_AWS_CPP_SDK_GAMELIFT_ANDROID_21
  • STLIB_AWS_CPP_SDK_GAMELIFT_STATIC
  • STLIB_AWS_CPP_SDK_GAMELIFT_STATIC_ANDROID_21
    If you happen to find ‘LIB_AWS_CPP_SDK_GAMELIFT’ exactly, then something during the configure step broke.

In regards to you’re previous question, the issues are related. The AWS core shared library is marked as a dependency in the GameLift shared library. So when the dynamic linker goes to load GameLift, it searches for it’s dependencies first but can’t find them. Those changes from earlier in the thread are only delaying the original issue from happening even if only by fractions of a second. The root problem is that the GameLift shared library is getting included in a release build when it shouldn’t be.

RESOLVED! Answer here…

https://forums.awsgametech.com/t/android-release-cant-find-gamelift-shared-library/6079/1

Did you solve this problem?

https://forums.awsgametech.com/t/android-release-cant-find-gamelift-shared-library/6079/1

The link to fix the problem is broken.
I’m having the same problem.

Hi @JUN -

The resolution (at the link) was as follows:

In the GameLift Gem wscript update the uses for both Android and iOS to use the plain version of AWS_CPP_SDK_GAMELIFT instead of the _SHARED version. This way the build type (e.g. monolithic vs non-monolithic) will properly determine if the static or shared library (respectively) should be used.

Hope that helps :slight_smile:

Your advice has helped me.
Thank you. :grin:

1 Like