td: Unable to use Java pre built library for Android
Hi,
I am trying to use Telegram APIs in my application to login user to Telegram and then make some API calls. Documentation seems to suggest that we need to use TDLib for that.
There are examples for using TDLib in Java and also there is a prebuilt library too for Android. Unfortunately, for people like me who are not very familiar with these, it is not clear how to use these examples and libraries. They have tons of code written into them, and it is not easy to figure out which part of code is the one that is doing actual integration.
Was not sure how to include the pre built library, as there was no instruction for it on https://github.com/tdlib/td/blob/master/example/README.md#java . So, I have gone ahead with my guesswork.
So, I just unzipped what was at prebuilt library for Android and copied the “src/main/java/org” folder and everything below it to my app’s “java” folder. I suspect other files and folders in this unzipped library also must be of use, but unfortunately because of me being new to Android programming, I had no idea how to utilise it.
And then I added following import lines in my code.
import org.drinkless.td.libcore.telegram.TdApi
import org.drinkless.td.libcore.telegram.Client
Then I added code from Java Example to my application from example/java
Now with all this it is compiling the code. However, when I am running it, I am getting following error:
"No implementation found for org.drinkless.td.libcore.telegram.TdApi$Object org.drinkless.td.libcore.telegram.NativeClient.clientExecute(org.drinkless.td.libcore.telegram.TdApi$Object)"
Documentation on example/java says following:
"If you get java.lang.UnsatisfiedLinkError with "Can't find dependent libraries", you may also need to copy some dependent shared OpenSSL and zlib libraries to bin/."
Which are these “some dependent libraries”? Where do I get them? Also, is this message applicable to the error that I am getting? What I am getting is slightly different (I am getting “UnsatisfiedLinkError” but with “No implementation found” and not saying “Can’t find dependent libraries”.)
I now unzipped the pre-built library in another folder called ‘prebuilt-libtd’ and tried including jar file to dependencies, by including "gradle/wrapper/gradle-wrapper.jar"by adding following line:
implementation fileTree(dir: '/Users/mghatiya/AndroidStudioProjects/prebuilt-libtd/gradle/wrapper', include: ['*.aar', '*.jar'], exclude: [])
Not sure if this is the jar file that was intended. I couldn’t see any other jar file in the pre built library. However, the same error continues. I am clueless at the moment as to what else can I try.
Please guide where am I going wrong.
Thanks for the help.
Thanks, Mukesh
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (5 by maintainers)
Thanks for the answer.
So, I did following:
implementation fileTree(dir: '/Users/.....lineI was getting following errors while running the code:
And
Then I copied the content of prebuilt library’s “libs” folder to my app’s libs folder and changed the gradle file’s
sourceSetsline to this:And it seems to be working as of now. Did I do it in the right way?
I am getting some other errors, which I probably should research a bit on and open another thread if required, but at least the library seems to be getting connected.
Thanks, Mukesh