Override getMainSharedObject()

This theoretically allows LOVE libs not to be extracted in Marshmallow
and later by utilizing extractNativeLibs=false. However this is left to
users (developer) to decide whetever to use this or not.
This commit is contained in:
Miku AuahDark
2019-07-20 20:49:25 +08:00
parent 2529265eed
commit 78e88a7473
@@ -45,14 +45,30 @@ public class GameActivity extends SDLActivity {
@Override
protected String[] getLibraries() {
return new String[]{
"c++_shared",
"mpg123",
"openal",
"hidapi",
"love",
"c++_shared",
"mpg123",
"openal",
"hidapi",
"love",
};
}
@Override
protected String getMainSharedObject() {
String[] libs = getLibraries();
String libname = "lib" + libs[libs.length - 1] + ".so";
// Since Lollipop, you can simply pass "libname.so" to dlopen
// and it will resolve correct paths and load correct library.
// This is mandatory for extractNativeLibs=false support in
// Marshmallow.
if (android.os.Build.VERSION.SDK_INT >= 21) {
return libname;
} else {
return getContext().getApplicationInfo().nativeLibraryDir + "/" + libname;
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.d("GameActivity", "started");