Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inaccurate android detection when outside of termux environment #1210

Open
alexytomi opened this issue Nov 9, 2024 · 2 comments
Open

Inaccurate android detection when outside of termux environment #1210

alexytomi opened this issue Nov 9, 2024 · 2 comments

Comments

@alexytomi
Copy link

alexytomi commented Nov 9, 2024

Describe the bug
When attempting to use a Minecraft Java mod (Distant Horizons) under PojavLauncher (a Minecraft Java launcher for phones) which uses this library to store level data, it picks the drivers for Linux instead of Linux-Android, failing and crashing

Environment:

  • OS: Android 13 OneUI 5.1
  • CPU architecture: arm64
  • sqlite-jdbc version: sqlite-3.43.0.0

Additional context
Using -Dos.name seems to be something that should work, but due to Minecraft just outright crashing when it's set to Android, it's not an option for this situation.

The current workaround is to either load the Linux-Android libraries using another mod, putting it inside the JRE, or overwriting the Linux libraries with Linux-Android ones.

@gotson
Copy link
Collaborator

gotson commented Nov 11, 2024

this is how the detection works for Android now:

public static boolean isAndroidRuntime() {
return System.getProperty("java.runtime.name", "").toLowerCase().contains("android");
}
public static boolean isAndroidTermux() {
try {
return processRunner.runAndWaitFor("uname -o").toLowerCase().contains("android");
} catch (Exception ignored) {
return false;
}
}

Most likely the launcher you are using does not fit in those 2 cases.

@alexytomi
Copy link
Author

this is how the detection works for Android now:

public static boolean isAndroidRuntime() {
return System.getProperty("java.runtime.name", "").toLowerCase().contains("android");
}
public static boolean isAndroidTermux() {
try {
return processRunner.runAndWaitFor("uname -o").toLowerCase().contains("android");
} catch (Exception ignored) {
return false;
}
}

Most likely the launcher you are using does not fit in those 2 cases.

It doesn't fit in isAndroidTermux() but I can set -Djava.runtime.name=android yet that has no effect.

I also tried -Djava.runtime.name="Java for Android" yet it also has no effect

@gotson gotson added enhancement and removed triage labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants