How to compile telegram jni folder

2019-03-29 04:23发布

问题:

I am trying to compile jni folder in telegram source code in github.com/DrKLO/Telegram/ with ndk

But when i am write ndk-build in cmd in ndk folder like:

F:\ndk\android-ndk-r10>ndk-build -C F:\Workspace\Android\Telegram-master-1-12-2016\Telegram-master\TMessagesProj\jni

I get some error and libs folder not created

When i add ndk path to android studio and add jni folder manually android studio say can not find some header files

Following this question download Cygwin and use it, but again get this error like ndk-build

$ndkbuild

[armeabi] SharedLibrary : libtmessages.15.so

process_begin: CreateProcess(........,

F:/ndk/android-ndk-r10/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi /thumb/libgnustl_static.a -lgcc -no-canonical-prefixes -Wl,--no-undefined -Wl,-z ,noexecstack -Wl,-z,relro -Wl,-z,now -LF:/ndk/android-ndk-r10/platforms/android- 9/arch-arm/usr/lib -ljnigraphics -llog -lz -ldl -lc -lm -o F:/Workspace/Android/ Telegram-master-1-12-2016/Telegram-master/TMessagesProj//obj/local/armeabi/libtm essages.15.so, ...) failed

make (e=87): The parameter is incorrect.

make.exe: *** [F:/Workspace/Android/Telegram-master-1-12-2016/Telegram-master/TMessagesProj//obj/local/armeabi/libtmessages.15.so] Error 87

How fix this?

回答1:

Important update issue: in 3.18 version, after downloading telegram source project, if you go to jni folder you will find and empty folder named libtgvoip, to fill it with needed files: 1- go to telegram source from githum, goto jni folder and click on libtgvoip @ eb813e1 folder (@ means that this is a refrence folder). 2- download that library too! 3- copy its content in empty folder discussed earlier!

Now lets begin: Its very easy.

1- Add NDK directory to environment PATH 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 command prompt as administrator and navigate to jni folder like this: (important: in last version of telegram you should navigate to jni parent folder instead of jni folder)

5- just execute ndk-build command

Then ndk will start building .so files:

wait until it finish the task, maybe some warnings displayed but not important. finally you will have all shared library (.so files) in the obj directory: (important: in last version of telegram .so files will create in lib folder and everything is ready to build)

then goto each of these folders and delete everything except libtmessages.22.so. create a libs folder and copy that three directory into it:

Build and have fun! (remember to fill out variables in org.telegram.messenger.BuildVars class with your app id and app_hash. read more here)



回答2:

Just remove the object file. This error most likely appeared after the previous build was interrupted and object file was not generated completely.



回答3:

Download the android-ndk Then go to the Project directory (./TMessagesProj) and execute ndk-build. Then re-run the gradle build which packages the native libs into the apk.