openziti / ziti-sdk-jvm

Ziti SDK for JVM
https://openziti.org
Apache License 2.0
58 stars 13 forks source link

Application Crashes when i run ZitiContext.dial(serviceName: String) #613

Open BawazierMurphy opened 4 months ago

BawazierMurphy commented 4 months ago

Issue Description I encountered a java.lang.UnsatisfiedLinkError when trying to use the ZitiContext.dial(serviceName: String) function in my Flutter application. The Flutter app uses a Flutter MethodChannel to call Kotlin functions.

Deps

Code Here is the code where the error occurs:

                val name = (call.arguments as Map<*, *>)["name"] as String;
                val ctx: ZitiContext? = OpenZitiPlugin.getContextByName(name = name)
                if(ctx != null){
                    Toast.makeText(
                        context,
                        "Context Found",
                        Toast.LENGTH_LONG
                    ).show()
                    OpenZitiPlugin.dial(ctx, "xxxx") // the error occurred here
                    Toast.makeText(
                        context,
                        "Connected",
                        Toast.LENGTH_LONG
                    ).show()
                } else {
                    Toast.makeText(
                        context,
                        "Context Not Found",
                        Toast.LENGTH_LONG
                    ).show()
                }

inside OpenZitiPlugin.dial()

        fun dial(ctx: ZitiContext, serviceName: String) {
            ctx.dial(serviceName)
        }

Error Log The following is the stack trace of the error:

FATAL EXCEPTION: DefaultDispatcher-worker-7
Process: com.durastha_mobile.carakan.id, PID: 15183
java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/android-aarch64/libjnidispatch.so) not found in resource path (.)
    at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1059)
    at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:1015)
    at com.sun.jna.Native.<clinit>(Native.java:221)
    at com.goterl.lazysodium.SodiumAndroid.<init>(SodiumAndroid.java:36)
    at com.goterl.lazysodium.SodiumAndroid.<init>(SodiumAndroid.java:17)
    at org.openziti.android.crypto.AndroidCryptoLoader.load(AndroidCryptoLoader.kt:26)
    at org.openziti.crypto.Crypto.<clinit>(Crypto.kt:49)
    at org.openziti.net.ZitiSocketChannel.connectInternal$ziti(ZitiSocketChannel.kt:149)
    at org.openziti.net.ZitiSocketChannel$connectInternal$1.invokeSuspend(Unknown Source:15)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@2ac4c76, Dispatchers.IO]

Expected Behavior The code should be successfully running without crashing.

Actual Behavior The application crashes force exit with a java.lang.UnsatisfiedLinkError.

Additional Information

ekoby commented 2 months ago

are you building for android?