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

Failed to load native library when running in Termux #789

Closed
AdorableParker opened this issue Sep 21, 2022 · 5 comments · Fixed by #796
Closed

Failed to load native library when running in Termux #789

AdorableParker opened this issue Sep 21, 2022 · 5 comments · Fixed by #796

Comments

@AdorableParker
Copy link

This works fine on Windows, according to the README.md, it should also work adaptively on Termux, but it doesn't, am I doing something wrong?

Codes

class MySQLiteTool(private val library: Path) {
    val connection: Connection by lazy {
        Class.forName("org.sqlite.JDBC")
        DriverManager.getConnection("jdbc:sqlite:$library")
    }
...
dependencies {
    implementation("org.xerial:sqlite-jdbc:3.39.3.0")
}

Logs

Failed to load native library:jansi-2.4.0-2db311a958a8e929-libjansi.so. osinfo: Linux/arm64
java.lang.UnsatisfiedLinkError: /data/data/com.termux/files/usr/tmp/jansi-2.4.0-2db311a958a8e929-libjansi.so: dlopen failed: library "libc.so.6" not found: needed by /data/data/com.termux/files/usr/tmp/jansi-2.4.0-2db311a958a8e929-libjansi.so in namespace (default)
...
...
2022-09-21 10:17:22 W/stderr: Failed to load native library:sqlite-3.36.0.3-ffd4f25b-64e0-4683-a009-8a70f7c36428-libsqlitejdbc.so. osinfo: Linux/aarch64
2022-09-21 10:17:22 W/stderr: java.lang.UnsatisfiedLinkError: /data/data/com.termux/files/usr/tmp/sqlite-3.36.0.3-ffd4f25b-64e0-4683-a009-8a70f7c36428-libsqlitejdbc.so: dlopen failed: library "libc.so.6" not found: needed by /data/data/com.termux/files/usr/tmp/sqlite-3.36.0.3-ffd4f25b-64e0-4683-a009-8a70f7c36428-libsqlitejdbc.so in namespace (default)
2022-09-21 10:17:22 E/AzurLaneLibrary: java.sql.SQLException: Error opening connection
java.sql.SQLException: Error opening connection
## Termux App Info
**APP_NAME**: `Termux`  
**PACKAGE_NAME**: `com.termux`  
**VERSION_NAME**: `0.118.0`  
**VERSION_CODE**: `118`  
**TARGET_SDK**: `28`  
## Device Info
### Hardware
**SUPPORTED_ABIS**: `arm64-v8a, armeabi-v7a, armeabi`  
@gotson
Copy link
Collaborator

gotson commented Sep 21, 2022

What's termux? What is the hardware you run that on?

@AdorableParker
Copy link
Author

termux is this termux app
I am running as a jar on an android device

@gotson
Copy link
Collaborator

gotson commented Sep 21, 2022

Seems like Termux reports as Linux instead of Android, and the native lib can't be loaded because of that.

To confirm this, you could try specifying the library path https://github.com/xerial/sqlite-jdbc/blob/master/USAGE.md#how-to-use-a-specific-native-library and try to load the android lib instead https://github.com/xerial/sqlite-jdbc/tree/master/src/main/resources/org/sqlite/native/Linux-Android

@gotson
Copy link
Collaborator

gotson commented Sep 21, 2022

You can also do some tests to find why this doesn't work on your system :

return System.getProperty("java.runtime.name", "").toLowerCase().contains("android");

@AdorableParker
Copy link
Author

ok i will try it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants