Important update problem: in version 3.18, after downloading the original telegram project, if you go to the jni folder, you will find an empty folder called libtgvoip to fill it with the necessary files: 1- go to the telegram source from githum, goto jni folder and click on the libtgvoip @ eb813e1 folder (@ means that this is the refrence folder). 2- download this library too! 3- copy its contents to the empty folder discussed earlier!
Now let's get started: It's very easy.
1- Add the NDK directory to the PATH environment variable.
2- open Android.mk and add the following line: LOCAL_SHORT_COMMANDS: = true

3- open Application.mk and add the following line: APP_SHORT_COMMANDS: = true

4- open the command line as an administrator and go to the jni folder as follows: (important: in the latest version of the telegram, you must go to the jni parent folder instead of the jni folder)

5 just run the ndk-build command

Then ndk will start creating .so files:

Wait for it to complete the task, maybe some warnings are displayed, but not important. finally, you will have the entire shared library (.so files) in the obj directory: (important: in the latest version of the telegram .so files will be created in the lib folder and everything will be ready to be created)

then go to each of these folders and delete everything except libtmessages.22.so. create the libs folder and copy three directories into it:

Build and have fun! (don't forget to populate the variables in the org.telegram.messenger.BuildVars class with your app id and app_hash. read more here )
source share