project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/frontlib/Flib.java
branchhedgeroid
changeset 15512 45d6806548e9
parent 10017 de822cd3df3a
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/frontlib/Flib.java	Sat Dec 07 16:14:27 2019 +0100
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/frontlib/Flib.java	Sat Dec 07 16:18:20 2019 +0100
@@ -27,14 +27,37 @@
 import com.sun.jna.Native;
 
 public class Flib {
-    static {
-        System.loadLibrary("SDL");
-        System.loadLibrary("SDL_net");
+    protected final static String[] libs = {
+        "SDL2",
+        "SDL2_net",
+    };
+
+    static{
+        for (String l : libs) {
+            try {
+                android.util.Log.d("org.hedgewars.hedgeroid.frontlib.Flib", "Hedgewars (class Flib) is attempting to load library '" + l + "' ...");
+                System.loadLibrary(l);
+                android.util.Log.d("org.hedgewars.hedgeroid.frontlib.Flib", "Hedgewars (class Flib) successfully loaded library '" + l + "'.");
+            } catch (Exception ex) {
+                android.util.Log.e("org.hedgewars.hedgeroid.frontlib.Flib", "Hedgewars (class Flib) failed to load library '" + l + "':" + ex.getMessage());
+                throw ex;
+            }
+        }
         System.setProperty("jna.encoding", "UTF8"); // Ugly global setting, but it seems JNA doesn't allow setting this per-library...
     }
-    public static final Frontlib INSTANCE = (Frontlib)Native.loadLibrary("frontlib", Frontlib.class, Collections.singletonMap(Library.OPTION_TYPE_MAPPER, AndroidTypeMapper.INSTANCE));
+    public static final Frontlib INSTANCE;
 
     static {
+        String l = "frontlib";
+        try {
+            android.util.Log.d("org.hedgewars.hedgeroid.frontlib.Flib", "Hedgewars (class Flib) is attempting to singleton-load library '" + l + "' ...");
+            INSTANCE = (Frontlib)Native.loadLibrary(l, Frontlib.class, Collections.singletonMap(Library.OPTION_TYPE_MAPPER, AndroidTypeMapper.INSTANCE));
+            android.util.Log.d("org.hedgewars.hedgeroid.frontlib.Flib", "Hedgewars (class Flib) successfully loaded library '" + l + "'.");
+        } catch (Exception ex) {
+            android.util.Log.e("org.hedgewars.hedgeroid.frontlib.Flib", "Hedgewars (class Flib) failed to load library '" + l + "':" + ex.getMessage());
+            throw ex;
+        }
+
         // We'll just do it here and never quit it again...
         if(Flib.INSTANCE.flib_init() != 0) {
             throw new RuntimeException("Unable to initialize frontlib");