libgdx / gdx-liftoff

A modern setup tool for libGDX Gradle projects
Apache License 2.0
524 stars 48 forks source link

Use relinker in Android #158

Open fourlastor opened 3 months ago

fourlastor commented 3 months ago

This PR changes the default gdx native loader to relinker, to fix some issues in loading native libraries in Android SDK < 23

Berstanio commented 3 months ago

This would only work for libGDX core natives, not any extension which is probably also relevant. If ReLinker is really the better way to load natives on android, I think we rather need a way to implement it here: https://github.com/libgdx/gdx-jnigen/blob/c2a35efd7d22e958f777d4703c0545114cc747fd/gdx-jnigen-loader/src/main/java/com/badlogic/gdx/utils/SharedLibraryLoader.java#L168

or provide a way to override the default behaviour with something like SharedLibraryLoader#androidNativeLoader

tommyettinger commented 3 months ago

Yeah, this does only load libGDX with ReLinker... I'm not even sure if Box2D would be loaded by ReLinker with this PR, and it's used in a lot of Android games. Switching the minimum SDK version to 23 seems like it should work, I just don't know how many devices would be affected. That's over 10 versions back from the current version, right?

fourlastor commented 3 months ago

I think what you're saying makes sense, sorry for the late reply! I'll work on this as soon as I have some time (likely this weekend/next week)

fourlastor commented 3 months ago

Switching the minimum SDK version to 23 seems like it should work, I just don't know how many devices would be affected. That's over 10 versions back from the current version, right?

If that would be the case, yes, I do have reports of failing to load shared libraries (even with relinker) up to Android 12 though (API 31-32), so I'm not entirely sold on that. 12 is a significantly lower percentage of the market (see https://apilevels.com/)