Skip to content

Commit c340142

Browse files
NativeLibraryLoader: always fall back to Android if not macOS/Windows.
#605
1 parent dcb4b7a commit c340142

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

objectbox-java/src/main/java/io/objectbox/internal/NativeLibraryLoader.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ public class NativeLibraryLoader {
4242
static {
4343
String libname = OBJECTBOX_JNI;
4444
String filename = libname + ".so";
45-
boolean isLinux = false;
45+
// Some Android devices are detected as neither Android or Linux below,
46+
// so assume Linux by default to always fallback to Android
47+
boolean isLinux = true;
4648
// For Android, os.name is also "Linux", so we need an extra check
4749
// Is not completely reliable (e.g. Vivo devices), see workaround on load failure
4850
// Note: can not use check for Android classes as testing frameworks (Robolectric)
@@ -53,15 +55,16 @@ public class NativeLibraryLoader {
5355
String sunArch = System.getProperty("sun.arch.data.model");
5456
String cpuArchPostfix = "32".equals(sunArch) ? "-x86" : "-x64";
5557
if (osName.contains("windows")) {
58+
isLinux = false;
5659
libname += "-windows" + cpuArchPostfix;
5760
filename = libname + ".dll";
5861
checkUnpackLib(filename);
5962
} else if (osName.contains("linux")) {
60-
isLinux = true;
6163
libname += "-linux" + cpuArchPostfix;
6264
filename = "lib" + libname + ".so";
6365
checkUnpackLib(filename);
6466
} else if (osName.contains("mac")) {
67+
isLinux = false;
6568
libname += "-macos" + cpuArchPostfix;
6669
filename = "lib" + libname + ".dylib";
6770
checkUnpackLib(filename);

0 commit comments

Comments
 (0)