Description
While executing the Aws::InitAPI(Aws::SDKOptions) on Android the application is getting crashed.
Same code works fine for Windows.
I am simplifying the explanation by mentioning the exact steps I followed.
Note: The SWIG part for generating the JNI Wrapper is test OK and its working fine. SO you can ignore that part while analysis.
Following are the steps that I have followed to create my own cross platform static library project that consumes required AWS SDK libraries.
- Built the AWS C++ SDK libraries using CMake for Android and Windows
- Created a cross platform C++ static library project in VS2017.
- My static lib project exposes only one API e.g. 'MyAWSWrapper::listS3Bucket()'.
- Added all required dependent AWS Libraries dependencies in project setting for each platform in VS
- Built the project for Android and Windows which resulted into a '.so' and '.lib' files.
Following is what I did for Android on top of above steps:
- Generated JNI Wrapper files for my exposed C++ static library interface using 'SWIG'
- Created a Android wrapper project which consumes the AWS Android SDK '.so' files and one mine '.so' files
- Result of this Android wrapper project is a '.aar'
- Created a single butoon Android UI project which makes calls to this C++ library through Wrapper
- The implementation class of C++ interface gets called successfully and when reached at line wher I have made call to Aws::InitAPI(Aws::SDKOptions), application crashesh. The crash log is pasted at bottom.
Following is what I did for Windows on top of steps mentioned on first bullet:
- Created a C++ Windows console application
- Linked the required AWS SDK '*.lib' and my '*.lib' libraries in 'Linker -> Input ->Additional dependencies'
- Project got built successfully.
- While launch it was expecting the 'dll' files for all libraries that I had added in 'Linker -> Input ->Additional dependencies' VS project.
- Then I copied all the dll's where the C++ console application's executable was residing.
- Built the console application again
- Ran the application and call for Aws::InitAPI(Aws::SDKOptions) succeeded with no error.
- Further to this wrote code to List the S3 buckets inside same library which used AWS S3 SDK, and succeeded without any error.
Why is Android failing to initialize? Have I missed anything while building the Android SDK libraries?
What platform/OS are you using?
Android
What compiler are you using? what version?
Clang 5.0
What's your CMake arguments?
cmake -DCUSTOM_MEMORY_MANAGEMENT=0 -DBUILD_ONLY="cognito-identity;core;identity-management;s3;sts" -DTARGET_ARCH=ANDROID -DANDROID_ABI=armeabi-v7a ~/git/aws-sdk-cpp
Can you provide a TRACE level log? (sanitize any sensitive information)
--------- beginning of crash
2019-03-01 17:10:23.029 22640-22640/com.example.sample.awstester A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x1 in tid 22640 (sample.awstester)
2019-03-01 17:10:23.078 22718-22718/? E/propClient: PropClient failed to load
2019-03-01 17:10:23.110 22719-22719/? I/crash_dump32: obtaining output fd from tombstoned
2019-03-01 17:10:23.111 1191-1191/? I//system/bin/tombstoned: received crash request for pid 22640
2019-03-01 17:10:23.113 22719-22719/? I/crash_dump32: performing dump of process 22640 (target tid = 22640)
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: Build fingerprint: 'Verizon/hero2qltevzw/hero2qltevzw:8.0.0/R16NW/G935VVRS8CRK2:user/release-keys'
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: Revision: '15'
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: ABI: 'arm'
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: pid: 22640, tid: 22640, name: sample.awstester >>> com.example.sample.awstester <<<
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: Cause: null pointer dereference
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: r0 00000001 r1 00000001 r2 d13ea1a4 r3 00000041
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: r4 ef9c9234 r5 00000000 r6 00000000 r7 ffd0d7f0
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: r8 0000004a r9 eef74000 sl ffd0d850 fp ffd0d548
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: ip d13dcbe4 sp ffd0d540 lr d102ddbc pc d114eac8 cpsr 600f0010
2019-03-01 17:10:23.153 22719-22719/? A/DEBUG: backtrace:
2019-03-01 17:10:23.153 22719-22719/? A/DEBUG: #00 pc 001f9ac8 /data/app/com.example.sample.awstester-K9sGZKePIlELp6UedDMOPw==/lib/arm/libaws-cpp-sdk-core.so (_ZN3Aws5Utils6Memory25InitializeAWSMemorySystemERNS1_21MemorySystemInterfaceE+84)
2019-03-01 17:10:23.153 22719-22719/? A/DEBUG: #1 pc 000d8db8 /data/app/com.example.sample.awstester-K9sGZKePIlELp6UedDMOPw==/lib/arm/libaws-cpp-sdk-core.so (_ZN3Aws7InitAPIERKNS_10SDKOptionsE+44)
2019-03-01 17:10:23.153 22719-22719/? A/DEBUG: #2 pc 00069b95 /data/app/com.example.sample.awstester-K9sGZKePIlELp6UedDMOPw==/lib/arm/libAWSServicesProviderD.so (_ZN19AWSServicesProviderC1Ev+56)
2019-03-01 17:10:23.153 22719-22719/? A/DEBUG: #3 pc 000695f5 /data/app/com.example.sample.awstester-K9sGZKePIlELp6UedDMOPw==/lib/arm/libAWSServicesProviderD.so (Java_com_testdomain_AWSServicesProviderWrapper_AWSServicesProviderWrapperJNI_new_1AWSServicesProvider+40)