How to compile telegram jni folder
Asked Answered
E

3

7

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?

Electrophotography answered 12/1, 2016 at 14:0 Comment(10)
For some error you need some fix.Nessi
Often, switching to Cygwin for NDK build creates more problems than it resolves. Which errors did you see with the first (ndk-build.cmd - based) attempt? Use ndk-build V=1 to display all the actual commands as they unwrap.Bloodstain
@AlexCohn fatal error: sys/ucontext.h: No such file or directoryElectrophotography
If you used V=1, you have the command that caused this fatal error, please post itBloodstain
@AlexCohn ndk-build output hereElectrophotography
My NDK (r10d) has file platforms/android-9/arch-arm/usr/include/sys/ucontext.h; what about your F:\ndk\android-ndk-r10\platforms\android-9\arch-arm\usr\include\sys\ucontext.h?Bloodstain
@AlexCohn ucontext.h file not in sys folder, i am download ndk from android developer but why not complete?Electrophotography
Maybe you need to reinstall NDK, maybe also download it again from dl.google.com/android/ndk/android-ndk-r10e-windows-x86_64.exeBloodstain
@AlexCohn thanks. compile finish successfullyElectrophotography
@AlexCohn I use your comment syntax and my build complete successfully thank u man.Infirm
P
15

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

enter image description here

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

enter image description here

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)

enter image description here

5- just execute ndk-build command

enter image description here

Then ndk will start building .so files:

enter image description here

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)

enter image description here

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

enter image description here

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)

Puff answered 10/9, 2016 at 8:0 Comment(2)
You don't really need LOCAL_SHORT_COMMANDS := true in the Android.mk file because APP_SHORT_COMMANDS := true already covers all modules. See hereMarduk
I just done all of this but get this error and do not know what to do: Error:org.xml.sax.SAXParseException; lineNumber: 0; columnNumber: 0; cvc-pattern-valid: Value 'extras;intel - Copy;Hardware_Accelerated_Execution_Manager' is not facet-valid with respect to pattern '[a-zA-Z0-9_\-;.]+' for type 'segmentListType'. plz help meAlbertalberta
E
1

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

Eightieth answered 2/5, 2016 at 12:55 Comment(0)
L
1

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.

Loyalist answered 19/3, 2018 at 2:36 Comment(2)
Can you add link from where it can be downloadedTwentieth
This is my build process jianshu.com/p/dc9491d537d7,The file is too big for me to go to SichuanLoyalist

© 2022 - 2024 — McMap. All rights reserved.