Replies: 2 comments
-
Just wanted to say that I have read this — I have not come up with much useful to reply with yet, as it's been a little while since I was last trying to do anything with the JNI (or even with Android at all.) But I really like the idea, and I want to encourage you to experiment with it. I would love to see a cosmopolitan binary that can also be installed as a phone app. |
Beta Was this translation helpful? Give feedback.
0 replies
-
cosmocc binaries support running on Android since 78d3b86 back in July. Enjoy! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Someone tell me if this is a crazy idea...
With Cosmopolitan supporting ARM64 and the use of ZIP as a container, my mind immediately went to Android, where apps are distributed as APK files, which are simply ZIP files. I'm wondering if Cosmopolitan might target Android.
For a template about Android app development in C, I found https://github.com/cnlohr/rawdrawandroid
It would seem straightforward to combine a Cosmopolitan program for e.g. ARM64-Linux with an APK for ARM64-Android:
(Of course there are other files in the ZIP container, required by Android, such as AndroidManifest.xml).
But this isn't really in the spirit of actually portable executables, because the application code is duplicated.
Here's what I'm thinking about: Build a portable binary for ARM64-Linux + ARM64-Android and put that in the ZIP container with compression mode = none (
zip -0
). Then have a small loader code for ARM64-Linux that jumps to that location within the file.There is a bit of a mismatch in the nature of typical programs where Cosmopolitan comes from, mainly command-line interfaces, and a typical Android app on the other hand. But I think it would be a good fit for something like the Redbean server, where you could simply launch a WebView to interact with it.
I really don't have enough Android knowledge so before diving into this I'm posting this here. My hope is that someone can tell me why it won't work before I spend a lot of time on it.
One problem I see is that the shared library (*.so) required by Android is not in a format that can be simply "jumped into", because the normal usage is for the run-time linker to mangle it somehow.
Of course all of this glosses over the big effort needed to actually provide all the functionality to be able to run something like redbean on Android. But I think the problem of how to launch code in such a way is interesting in itself and would have to be solved first.
Beta Was this translation helpful? Give feedback.
All reactions