Android Telegram App --> java.lang.UnsatisfiedLinkError: No implementation found for void

stavasknall picture stavasknall · Nov 17, 2015 · Viewed 10.8k times · Source

Unfortunally a similar question was removed at Stackoverflow some weeks ago, I must make a new question.

Im trying to build an own Telegram app for android via source @ https://github.com/DrKLO/Telegram

I can not get it to work, it stops on startup with the following error, any ideas on where to start, Im quite new to Android Studio.

11-17 19:55:04.142 2667-2667/org.telegram.messenger E/art: No implementation found for void org.telegram.tgnet.ConnectionsManager.native_setJava(boolean) (tried Java_org_telegram_tgnet_ConnectionsManager_native_1setJava and Java_org_telegram_tgnet_ConnectionsManager_native_1setJava__Z)
11-17 19:55:04.142 2667-2667/org.telegram.messenger D/AndroidRuntime: Shutting down VM
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime: FATAL EXCEPTION: main
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime: Process: org.telegram.messenger, PID: 2667
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime: java.lang.UnsatisfiedLinkError: No implementation found for void org.telegram.tgnet.ConnectionsManager.native_setJava(boolean) (tried Java_org_telegram_tgnet_ConnectionsManager_native_1setJava and Java_org_telegram_tgnet_ConnectionsManager_native_1setJava__Z)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime:     at org.telegram.tgnet.ConnectionsManager.native_setJava(Native Method)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime:     at org.telegram.messenger.ApplicationLoader.onCreate(ApplicationLoader.java:259)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime:     at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime:     at android.app.ActivityThread.-wrap1(ActivityThread.java)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:148)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5417)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
11-17 19:55:04.151 2667-2667/org.telegram.messenger E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Answer

Jesús Castro picture Jesús Castro · Dec 16, 2015

The main problem is that you're running the project without generating the native library from the C/C++ codes. Because of that project based on Telegram, which you point it out with the link, has the file Android.mk on the jni directory , you have to compile the code manually. I fixed that exception following these steps:

  • Check that build.gradle contains:

source version 3.13.1 and newer:

sourceSets.main.jniLibs.srcDirs = ['./jni/']

source version lower than 3.13.1:

    sourceSets.main {
       jniLibs.srcDirs = 'libs'
       jni.srcDirs = [] //disable automatic ndk-build call
    }
  • Download the NDK

Proceed according to your operating system.

Linux / Mac

$ cd <path-to-Telegram>/TMessagesProj
$ <path-to-ndk>/ndk-build

Windows

  • Download Cygwin
  • Add on .bashrc file, which is placed on Cygwin root directory (use some utility to find that file). In my case, the file was placed in C:\cygwin64\home\myuser.

    export ndkbuild=/cygdrive/partition_name/your_ndk_directory/ndk-build.cmd
    
  • Open the Cygwin terminal and move yourself towards the jni directory of the project:

    cd /cygdrive/your_partition_name/project_jni_directory_path
    
  • Write $ndkbuild and wait the compiler finishes its task. If this process is right, two directories will show up, obj and libs. Check that libs directory contains some library with .so extension. Finally, run the project.