Skip to content

Commit ab35062

Browse files
committed
add android detection to the libloader
1 parent 16d5a7f commit ab35062

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

  • common/src/main/java/dev/ryanhcode/sable/physics/impl/rapier

common/src/main/java/dev/ryanhcode/sable/physics/impl/rapier/Rapier3D.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ public class Rapier3D {
4040
loadLibrary();
4141
}
4242

43+
private static boolean isAndroid() {
44+
return System.getProperty("java.vendor", "").toLowerCase().contains("android")
45+
|| System.getProperty("java.vm.vendor", "").toLowerCase().contains("android")
46+
|| System.getProperty("java.runtime.name", "").toLowerCase().contains("android");
47+
}
48+
4349
private static String getNativeName() {
4450
final String arch;
4551
if (System.getProperty("os.arch").equals("arm") || System.getProperty("os.arch").startsWith("aarch64")) {
@@ -48,6 +54,10 @@ private static String getNativeName() {
4854
arch = "x86_64";
4955
}
5056

57+
if (isAndroid()) {
58+
return LIB_NAME + "_" + arch + "_android.so";
59+
}
60+
5161
final OS os = Util.getPlatform();
5262
if (os == OS.WINDOWS) {
5363
return LIB_NAME + "_" + arch + "_windows.dll";
@@ -67,7 +77,9 @@ private static void loadLibrary() {
6777
throw new FileNotFoundException("sable_rapier_binaries.zip.l4z");
6878
}
6979

70-
final Path dir = Paths.get(NATIVE_DIR);
80+
final Path dir = isAndroid()
81+
? Paths.get(System.getProperty("java.io.tmpdir"), ".sable")
82+
: Paths.get(NATIVE_DIR);
7183
if (!Files.exists(dir)) {
7284
Files.createDirectories(dir);
7385
}

0 commit comments

Comments
 (0)