Skip to content
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

Just curious: Do the binaries actually need the .so extension? #3

Closed
ChristianCiach opened this issue Jan 13, 2022 · 4 comments
Closed

Comments

@ChristianCiach
Copy link

ChristianCiach commented Jan 13, 2022

It's unusual to name executables using the "so" file extension. Is there anything in android that forces you to name the files that way? I see that you bundle the binaries as JNI libraries into the APK (which is maybe the reason for naming the files that way), but isn't it also possible to just package them as resources (for example using the processResources gradle task)?

There is no actual issue that I am trying to fix. I am just curious about some of the choices you've made.

That being said, I think your solution to the W^X issue is very elegant: Since android only allows the execution of binaries bundled with the APK, let's just put them into an APK. Nice! Luckily the Kodi extension uses sockets to communicate with the core process, otherwise we would have lot more work to do :)

Thanks for this project btw!

@StefanIlchev
Copy link
Owner

@ChristianCiach you are correct, the executables are renamed that way to look like shared objects because they are bundled as JNI libraries even though they are not. Otherwise they might not get extracted from the APK on install on some devices. It's a bit hacky but I don't know of any other way to get a file with execute permission on Android 10 and up.

When I noticed Elementum uses sockets for inter-process communication I realized how easy it would be to get it to work this way.

@ChristianCiach
Copy link
Author

Thanks!

@ChristianCiach
Copy link
Author

ChristianCiach commented Jan 13, 2022

Turns out, naming the binaries lib*.so is actually the only possible way to ship executables on modern Android. There are multiple entries on androids issue tracker regarding this issue and Google is aware of them. So you're actually doing it the "right" way.

That being said, I wonder how hard it is to build the elementum core as an actual library instead of an executable. I know you are currently just copying the executable from the official release artifact, so re-building it from source as a library is more work.

Your code and the gradle files seem quite hacky anyway. I briefly considered sending some PRs to clean up some stuff. But then again.... It's currently working fine and the development of Elementum has been mostly stopped anyway, so why bother? If it works, it works :)

@StefanIlchev
Copy link
Owner

So nothing has changed from the last time I looked into shipping executables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants