New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-5672] Compile swift file to .so library for armeabi-v7a is not recognized by Android #48242
Comments
Comment by Amr Aboelela (JIRA) I am finally able to run an Android app using a swift library. The main fix is to change the icu lib names to use swift suffix. I'll generate a pull request later to show how to do that in the Android.md file. Meanwhile, you can check: https://github.com/amraboelela/swift/blob/android/docs/Android.md Also you can check what I did in: |
Comment by Amr Aboelela (JIRA) I was still getting the java.lang.UnsatisfiedLinkError not found error, so I did the following to fix this issue: in app/build.graddle I replaced: defaultConfig { With: defaultConfig { Now after running, I can see the detailed calls for the compiling commands, so I got the following from Griddle Console in Android Studio: Build add-swift armeabi-v7a The Part which causes the problem is: /Users/aaboelela/android/AmrSwiftAndroid/AddSwiftApp/libs/armeabi-v7a/libAddSwift.so So I created my own shell script app/build.sh and replaced that part with -lAddSwift -L/Users/aaboelela/android/AmrSwiftAndroid/AddSwiftApp/libs/armeabi-v7a The full build.sh content is: mkdir -p CMakeFiles/add-swift.dir /Users/aaboelela/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang -target=armv7-none-linux-androideabi --gcc-toolchain=/Users/aaboelela/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64 --sysroot=/Users/aaboelela/Library/Android/sdk/ndk-bundle/sysroot -Dadd_swift_EXPORTS -isystem /Users/aaboelela/Library/Android/sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -D_ANDROID_API_=14 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-integrated-as -mthumb -Wa,-noexecstack -Wformat -Werror=format-security -O0 -fno-limit-debug-info -fPIC -MD -MT CMakeFiles/add-swift.dir/add-swift.c.o -MF CMakeFiles/add-swift.dir/add-swift.c.o.d -o CMakeFiles/add-swift.dir/add-swift.c.o -c /Users/aaboelela/android/AmrSwiftAndroid/AddSwiftApp/app/src/main/cpp/add-swift.c /Users/aaboelela/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang -target=armv7-none-linux-androideabi --gcc-toolchain=/Users/aaboelela/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64 --sysroot=/Users/aaboelela/Library/Android/sdk/ndk-bundle/sysroot -fPIC -isystem /Users/aaboelela/Library/Android/sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -D_ANDROID_API_=14 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-integrated-as -mthumb -Wa,noexecstack -Wformat -Werror=format-security -O0 -fno-limit-debug-info -Wl,exclude-libs,libgcc.a --sysroot /Users/aaboelela/Library/Android/sdk/ndk-bundle/platforms/android-14/arch-arm -Wl,build-id -Wl,warn-shared-textrel -Wl,fatal-warnings -Wl,fix-cortex-a8 -Wl,-no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libadd-swift.so -o /Users/aaboelela/android/AmrSwiftAndroid/AddSwiftApp/app/build/intermediates/cmake/debug/obj/armeabi-v7a/libadd-swift.so CMakeFiles/add-swift.dir/add-swift.c.o -landroid -llog -lAddSwift -L/Users/aaboelela/android/AmrSwiftAndroid/AddSwiftApp/libs/armeabi-v7a -lm Then I ran build.sh from terminal as: app$ ./build.sh Then I ran the project from Android Studio again then I passed that error. |
Comment by Amr Aboelela (JIRA) Now I am getting this error: 08-23 11:58:59.438 25922-25922/com.example.addswift A/SwiftRuntime: dlopen() failed on `/system/lib/libcutils.so': dlopen failed: library "/system/lib/libcutils.so" wasn't loaded and RTLD_NOLOAD prevented it
[ 08-23 11:58:59.451 645: 645 W/ ] |
Comment by Amr Aboelela (JIRA) Created a new bug for this https://bugs.swift.org/browse/SR-5757 |
I'm afraid that is well beyond my understanding. Any idea why that is trying to be opened? Also does that .so exist at that path? RTLD_NOLOAD should attempt to determine if it's there, but I believe it won't try to actually do the load. |
Additional Detail from JIRA
md5: 0e0d0fa99c372c5d06aa0c2e3bc05454
Issue Description:
Compiled as:
When tried to use libAddSwift.so into AddSwiftApp, got error from Android Studio as:
at
The text was updated successfully, but these errors were encountered: