tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.17k stars 1.45k forks source link

Adding TDLib to Android Studio #1576

Closed Onionus007 closed 3 years ago

Onionus007 commented 3 years ago

Hello everyone,

I am very new to java programming and I am having somewhat of an issue adding the provided pre-packaged TDLib instance to an Android Studio project. I have the .zip file and what appears to be a part of an Android Studio project but for the life of me I can't figure out what to do.

Would any of you be so kind as to provide me with a step-by-step instruction of what exactly I need to do to get it working?

levlam commented 3 years ago

https://stackoverflow.com/questions/24357687/how-to-include-so-library-in-android-studio

levlam commented 3 years ago

Also place provided Java wrapper files in the corresponding folder.

Onionus007 commented 3 years ago

By java wrapper you mean which files? Sorry, I am really really new to this

Onionus007 commented 3 years ago

And also, when I try to import the tdlib I for some reason get an error

Onionus007 commented 3 years ago

https://github.com/tdlib/td/blob/master/example/java/org/drinkless/tdlib/example/Example.java

I use this as a reference point for imports

levlam commented 3 years ago

If you want to create an Android app, you need TDLib build for Android. You can find a prebuild library at https://core.telegram.org/tdlib/tdlib.zip.

Onionus007 commented 3 years ago

Yeah yeah, thats what I have, do I just use this as a project file?

levlam commented 3 years ago

There is no project in the archive. You need to add java and so files from the archive to your project as specified in the StackOverflow answer.

Onionus007 commented 3 years ago

Yeah, that's what I did, but it still says that I can't import the tdlib module

levlam commented 3 years ago

How do you import it?

Onionus007 commented 3 years ago

I take the archive, unpack it, take the files from libtd/src/main/libs and create a jniLibs folder in the folder src/main for them and put them there. According to the stack overflow answer that's about it

levlam commented 3 years ago

Have you copied the corresponding Java classes to your project?

Onionus007 commented 3 years ago

To be perfectly clear, by that you mean Client.java, Nativeclient.java and TdApi.java, right?

levlam commented 3 years ago

Yes.

Onionus007 commented 3 years ago

Screenshot 2021-06-18 at 20 05 04

This is what I got atm

Onionus007 commented 3 years ago

And then I reference them by using import com.example.fima.Client; in my case

levlam commented 3 years ago

You must not change the package name.

Onionus007 commented 3 years ago

I just copied this: "package com.example.fima;" from my initial MainActivity.java

levlam commented 3 years ago

You must not change package of java classes. You must not change provided source files and place them in the expected directory.

Onionus007 commented 3 years ago

And then that would be it, I can simply import the classes?