Unsatisfied Link Error when loading sinch library in real device

1.4k Views Asked by At

I am trying a simple application on the lines of the sample messaging tutorial provided on the sinch tutorial website . I am getting a unsatisfied link error when I am trying to run the message service . I am using a real device and getting this error . Here's the

logcat

11-11 17:59:49.996: E/NativeCrypto(28765): ssl=0x5da485a8 cert_verify_callback x509_store_ctx=0x5f55cab0 arg=0x0
11-11 17:59:49.996: E/NativeCrypto(28765): ssl=0x5da485a8 cert_verify_callback calling verifyCertificateChain authMethod=RSA
11-11 17:59:51.576: E/AndroidRuntime(28765): FATAL EXCEPTION: main
11-11 17:59:51.576: E/AndroidRuntime(28765): java.lang.UnsatisfiedLinkError: Couldn't load sinch-android-rtc from loader dalvik.system.PathClassLoader[DexPathList[dexElements=[zip file "/data/app/com.andro_yce.dyad-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.andro_yce.dyad-2, /vendor/lib, /system/lib]]]: findLibrary returned null
11-11 17:59:51.576: E/AndroidRuntime(28765):    at java.lang.Runtime.loadLibrary(Runtime.java:359)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at java.lang.System.loadLibrary(System.java:514)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at com.sinch.android.rtc.internal.natives.jni.UserAgentFactory.<clinit>(UserAgentFactory.java:9)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at com.sinch.android.rtc.internal.client.ServiceFactory.createUserAgent(ServiceFactory.java:44)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at com.sinch.android.rtc.internal.client.DefaultSinchClient.<init>(DefaultSinchClient.java:157)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at com.sinch.android.rtc.internal.client.InternalSinchClientFactory.createSinchClient(InternalSinchClientFactory.java:14)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at com.sinch.android.rtc.DefaultSinchClientBuilder.build(DefaultSinchClientBuilder.java:95)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at com.andro_yce.dyad.MessageService.startSinchClient(MessageService.java:47)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at com.andro_yce.dyad.MessageService.onStartCommand(MessageService.java:37)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2819)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at android.app.ActivityThread.access$1900(ActivityThread.java:156)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1437)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at android.os.Looper.loop(Looper.java:153)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at android.app.ActivityThread.main(ActivityThread.java:5311)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at java.lang.reflect.Method.invokeNative(Native Method)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at java.lang.reflect.Method.invoke(Method.java:511)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
11-11 17:59:51.576: E/AndroidRuntime(28765):    at dalvik.system.NativeStart.main(Native Method)

This is how I start the messageservice

`   ParseUser currentUser = ParseUser.getCurrentUser();
    Intent serviceIntent = new Intent(this, MessageService.class);
    if (currentUser != null) {
        startService(serviceIntent);
    }
    showSpinner();
    private Intent broadcastIntent = new Intent("com.andro_yce.dyad.SplashActivity");

And this is my messageservice class

package com.andro_yce.dyad;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.support.v4.content.LocalBroadcastManager;

import com.parse.ParseUser;
import com.sinch.android.rtc.ClientRegistration;
import com.sinch.android.rtc.Sinch;
import com.sinch.android.rtc.SinchClient;
import com.sinch.android.rtc.SinchClientListener;
import com.sinch.android.rtc.SinchError;
import com.sinch.android.rtc.messaging.MessageClient;
import com.sinch.android.rtc.messaging.MessageClientListener;
import com.sinch.android.rtc.messaging.WritableMessage;

public class MessageService extends Service implements SinchClientListener {

private static final String APP_KEY = "**********";
private static final String APP_SECRET = "==========";
private static final String ENVIRONMENT = "sandbox.sinch.com";
private final MessageServiceInterface serviceInterface = new MessageServiceInterface();
private SinchClient sinchClient = null;
private MessageClient messageClient = null;
private String currentUserId;
private LocalBroadcastManager broadcaster;
private Intent broadcastIntent = new Intent("com.andro_yce.dyad.SplashActivity");

@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    currentUserId = ParseUser.getCurrentUser().getObjectId();

    if (currentUserId != null && !isSinchClientStarted()) {
        startSinchClient(currentUserId);
    }

    broadcaster = LocalBroadcastManager.getInstance(this);

    return super.onStartCommand(intent, flags, startId);
}

public void startSinchClient(String username) {
    sinchClient = Sinch.getSinchClientBuilder().context(this).userId(username).applicationKey(APP_KEY)
            .applicationSecret(APP_SECRET).environmentHost(ENVIRONMENT).build();

    sinchClient.addSinchClientListener(this);

    sinchClient.setSupportMessaging(true);
//     sinchClient.setSupportCalling(true);
    sinchClient.setSupportActiveConnectionInBackground(true);

    sinchClient.checkManifest();
    sinchClient.start();
}

private boolean isSinchClientStarted() {
    return sinchClient != null && sinchClient.isStarted();
}

@Override
public void onClientFailed(SinchClient client, SinchError error) {
    broadcastIntent.putExtra("success", false);
    broadcaster.sendBroadcast(broadcastIntent);

    sinchClient = null;
}

@Override
public void onClientStarted(SinchClient client) {
    broadcastIntent.putExtra("success", true);
    broadcaster.sendBroadcast(broadcastIntent);

    client.startListeningOnActiveConnection();
    messageClient = client.getMessageClient();
}

@Override
public void onClientStopped(SinchClient client) {
    sinchClient = null;
}

@Override
public IBinder onBind(Intent intent) {
    return serviceInterface;
}

@Override
public void onLogMessage(int level, String area, String message) {
}

@Override
public void onRegistrationCredentialsRequired(SinchClient client, ClientRegistration clientRegistration) {
}

public void sendMessage(String recipientUserId, String textBody) {
    if (messageClient != null) {
        WritableMessage message = new WritableMessage(recipientUserId, textBody);
        messageClient.send(message);
    }
}

public void addMessageClientListener(MessageClientListener listener) {
    if (messageClient != null) {
        messageClient.addMessageClientListener(listener);
    }
}

public void removeMessageClientListener(MessageClientListener listener) {
    if (messageClient != null) {
        messageClient.removeMessageClientListener(listener);
    }
}

@Override
public void onDestroy() {
    sinchClient.stopListeningOnActiveConnection();
    sinchClient.terminate();
}

public class MessageServiceInterface extends Binder {
    public void sendMessage(String recipientUserId, String textBody) {
        MessageService.this.sendMessage(recipientUserId, textBody);
    }

    public void addMessageClientListener(MessageClientListener listener) {
        MessageService.this.addMessageClientListener(listener);
    }

    public void removeMessageClientListener(MessageClientListener listener) {
        MessageService.this.removeMessageClientListener(listener);
    }

    public boolean isSinchClientStarted() {
        return MessageService.this.isSinchClientStarted();
    }
}
}

Please help . Thanks

1

There are 1 best solutions below

1
On BEST ANSWER

As per now as I can see

Your library couldn't be loaded

Thrown when an attempt is made to invoke a native for which an implementation could not be found. http://developer.android.com/reference/java/lang/UnsatisfiedLinkError.html

Please check this link https://stackoverflow.com/a/22121375/1761003

Please do post some code for better reply