Browse Source

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.
Miku AuahDark 6 years ago
parent
commit
78e88a7473
1 changed files with 21 additions and 5 deletions
  1. 21 5
      love/src/main/java/org/love2d/android/GameActivity.java

+ 21 - 5
love/src/main/java/org/love2d/android/GameActivity.java

@@ -45,14 +45,30 @@ public class GameActivity extends SDLActivity {
     @Override
     @Override
     protected String[] getLibraries() {
     protected String[] getLibraries() {
         return new String[]{
         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
     @Override
     protected void onCreate(Bundle savedInstanceState) {
     protected void onCreate(Bundle savedInstanceState) {
         Log.d("GameActivity", "started");
         Log.d("GameActivity", "started");