libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.92k stars 1.84k forks source link

Get SDL for Android published on Maven Central #6315

Closed madebr closed 1 week ago

madebr commented 2 years ago

The repo now contains a script to build an android prefab archive. The next problem is how to get these published to Maven Central, so SDL becomes available in all new Android gradle projects.

This requires a few checks and actions:

madebr commented 2 years ago

@slouken Creating an Android package for SDL would be easy because it has 0 dependencies. But for the satellite libraries, the situation will complicate a lot. For SDL_image: will we provide support for third party libraries such as zlib, libjpeg, .... For SDL_ttf: libHarfbuzz and libFreetype are a hard requirement. Same applies to SDL_mixer.

Since creating an Android AAR is only a matter of re-packaging, I think this should be left to package maintainers.

slouken commented 2 years ago

Do most projects use .android in their namespace?

madebr commented 2 years ago

To be honest, I don't have much experience with packages from the OSS maven repo. So far, I was only using dependencies from Google. My logic to include the .android is to make it clear it is for Android and it is not a java binding for example.

madebr commented 1 year ago

@slouken Would it be fine if we went ahead with this for SDL2 2.26.x?

Please register org.libsdl here. My username there is madebr (=useful to allow others make releases).

To prove ownership, you'll have to create a TXT record at libsdl.org (which we'll know after we've registered).

samuelgrigolato commented 1 year ago

Hey @madebr, just so you know I'm consuming a lot of your work with SDL2 on Android lately. It is a bit scattered around and I had to fill in some knowledge gaps here and there (NDK docs are very much lacking at times), but your prefab scripts helped me save a lot of hair, so kudos and thank you very much for making your scripts find their way to SDL's repos.

In the end I was able to run SDL2 + curl + SDL2_image on Android using local AAR prefab dependencies, but I agree that it would be easier if libsdl supported deploying official builds to a public maven repository. I would be willing to invest some time helping if you find two more hands would be great to have. I have experience with enterprise Java so it might come in handy.

slouken commented 1 year ago

This is on my list to look at once SDL3 changes slow down, thanks @madebr!

madebr commented 1 year ago

@ericoporto I think you commented in the wrong issue.

madebr commented 5 months ago

@slouken Since https://github.com/libsdl-org/SDL/commit/45081db9d41eaaf92c61da8acde4e7f11a0bf302, the build-release.py script creates an android SDL3-3.1.2.aar Android archive.

Do you intend to add these to the "official" release binaries?

If so, I'll need to add documentation to README-android.md.

slouken commented 5 months ago

I need to chat with you about how all the different Android builds work together. Can you send e-mail to slouken@libsdl.org to coordinate?

madebr commented 4 months ago

I just shot you a mail, and a friend request on Discord.

Thinking more about this issue. Perhaps it's more fitting for the SDL project to simply provide a SDL3 aar Android archive. The SDL project does currently also not provide "official" binaries for other package managers. Interested packagers can always respin the aar-chive, and publish it themselves.

My idea is to simply publish e.g. SDL3-3.1.2.aar, alongside the source, windows and apple archives. This archive can then be used in Android gradle projects by adding it to their dependencies. An example Android aarchive can be found at the bottom of this page.

slouken commented 4 months ago

This sounds like a good plan. This means that users don't have to build SDL themselves and can drop an official release into their builds. Let's go with that.

Should we change the existing android-project framework to reflect this model? Can/should we fix buildandroid.sh to set up a project using this?

madebr commented 4 months ago

Should we change the existing android-project framework to reflect this model? Can/should we fix buildandroid.sh to set up a project using this?

I went the NIH way, and replaced buildandroid.sh with create-android-project.py in #10177 The python script has identical behavior of the sh script, with the extra capability to create a project making use of prefab aar archives (--variant aar)

slouken commented 4 months ago

Sounds good.

madebr commented 4 months ago

Things left to do:

slouken commented 1 month ago

@madebr, can you do the documentation portion of this for SDL 3.2?

madebr commented 1 month ago

@madebr, can you do the documentation portion of this for SDL 3.2?

Can do :)

madebr commented 1 week ago

I think using the aar is documented in https://github.com/libsdl-org/SDL/blob/main/docs/README-android.md#using-the-sdl3-android-archive-aar

It's used in libsdl-org/SDL_helloworld here