Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
785 views
in Technique[技术] by (71.8m points)

java - UnsatisfiedLinkError: Couldn't load sinch-android-rtc from loader dalvik.system

I unexpectedly received the below error while trying to run my android application on the phone. Essentially in the application, it makes a call to messageservice so that I am able to run my instant messaging. I am using Sinch for android to handle my instant messaging.

Below is the log cat message:

10-08 00:34:31.550: E/AndroidRuntime(1610): FATAL EXCEPTION: main
10-08 00:34:31.550: E/AndroidRuntime(1610): Process: com.dooba.beta, PID: 1610
10-08 00:34:31.550: E/AndroidRuntime(1610): java.lang.UnsatisfiedLinkError: Couldn't load sinch-android-rtc from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.dooba.beta-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.dooba.beta-1, /system/lib]]]: findLibrary returned null
10-08 00:34:31.550: E/AndroidRuntime(1610):     at java.lang.Runtime.loadLibrary(Runtime.java:358)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at java.lang.System.loadLibrary(System.java:526)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at com.sinch.android.rtc.internal.natives.jni.UserAgentFactory.<clinit>(UserAgentFactory.java:9)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at com.sinch.android.rtc.internal.client.ServiceFactory.createUserAgent(ServiceFactory.java:44)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at com.sinch.android.rtc.internal.client.DefaultSinchClient.<init>(DefaultSinchClient.java:155)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at com.sinch.android.rtc.internal.client.InternalSinchClientFactory.createSinchClient(InternalSinchClientFactory.java:14)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at com.sinch.android.rtc.DefaultSinchClientBuilder.build(DefaultSinchClientBuilder.java:95)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at com.dooba.beta.MessageService.startSinchClient(MessageService.java:66)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at com.dooba.beta.MessageService.onStartCommand(MessageService.java:56)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2702)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at android.app.ActivityThread.access$2100(ActivityThread.java:135)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at android.os.Handler.dispatchMessage(Handler.java:102)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at android.os.Looper.loop(Looper.java:136)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at android.app.ActivityThread.main(ActivityThread.java:5017)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at java.lang.reflect.Method.invokeNative(Native Method)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at java.lang.reflect.Method.invoke(Method.java:515)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
10-08 00:34:31.550: E/AndroidRuntime(1610):     at dalvik.system.NativeStart.main(Native Method)

Below is the MessageService activity:

public class MessageService extends Service implements SinchClientListener {

    private static final String APP_KEY = "xxxxx";
    private static final String APP_SECRET = "xxxxx";
    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.dooba.beta.MessagingActivity1");

    @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.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();
        }
    }
}

Any help would be greatly appreciated.

Update Screens of the library added

enter image description here

enter image description here

![enter image description here][3]

Update 3 enter image description here

10-09 18:27:08.450: E/AndroidRuntime(999): FATAL EXCEPTION: main
10-09 18:27:08.450: E/AndroidRuntime(999): java.lang.ExceptionInInitializerError
10-09 18:27:08.450: E/AndroidRuntime(999):  at com.sinch.android.rtc.internal.client.ServiceFactory.createUserAgent(ServiceFactory.java:44)
10-09 18:27:08.450: E/AndroidRuntime(999):  at com.sinch.android.rtc.internal.client.DefaultSinchClient.<init>(DefaultSinchClient.java:157)
10-09 18:27:08.450: E/AndroidRuntime(999):  at com.sinch.android.rtc.internal.client.InternalSinchClientFactory.createSinchClient(InternalSinchClientFactory.java:14)
10-09 18:27:08.450: E/AndroidRuntime(999):  at com.sinch.android.rtc.DefaultSinchClientBuilder.build(DefaultSinchClientBuilder.java:95)
10-09 18:27:08.450: E/AndroidRuntime(999):  at com.dooba.beta.MessageService.startSinchClient(MessageService.java:56)
10-09 18:27:08.450: E/AndroidRuntime(999):  at com.dooba.beta.MessageService.onStartCommand(MessageService.java:40)
10-09 18:27:08.450: E/AndroidRuntime(999):  at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2490)
10-09 18:27:08.450: E/AndroidRuntime(999):  at android.app.ActivityThread.access$1900(ActivityThread.java:130)
10-09 18:27:08.450: E/AndroidRuntime(999):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
10-09 18:27:08.450: E/AndroidRuntime(999):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-09 18:27:08.450: E/AndroidRuntime(999):  at android.os.Looper.loop(Looper.java:137)
10-09 18:27:08.450: E/AndroidRuntime(999):  at android.app.ActivityThread.main(ActivityThread.java:4745)
10-09 18:27:08.450: E/AndroidRuntime(999):  at java.lang.reflect.Method.invokeNative(Native Method)
10-09 18:27:08.450: E/AndroidRuntime(999):  at java.lang.reflect.Method.invoke(Method.java:511)
10-09 18:27:08.450: E/AndroidRuntime(999):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
10-09 18:27:08.450: E/AndroidRuntime(999):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-09 18:27:08.450: E/AndroidRuntime(999):  at dalvik.system.NativeStart.main(Native Method)
10-09 18:27:08.450: E/AndroidRuntime(999): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load sinch-android-rtc: findLibrary returned null
10-09 18:27:08.450: E/AndroidRuntime(999):  at java.lang.Runtime.loadLibrary(Runtime.java:365)
10-09 18:27:08.450: E/AndroidRuntime(999):  at java.lang.System.loadLibrary(System.java:535)
10-09 18:27:08.450: E/AndroidRuntime(999):  at com.sinch.android.rtc.internal.natives.jni.UserAgentFactory.<clinit>(UserAgentFactory.java:9)
  [3]: http://i.stack.imgur.co

m/5Kx3e.png

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You will need to copy the sinch libraries to your project, please see the sinch client for android documentation

download the sinch android sdk zip , copy the contents of libs folder into the libs under your project root.

clean and rebuild the project. Before testing the apk, open the apk as a zip and make sure .so files are in lib* folder;

if you are having trouble getting eclipse to properly package the app, please consider using sinch's documentation and use android studio as they suggest


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...