Telegram-X

This is the complete source code and the build instructions for the official alternative Android client for the Telegram messenger, based on the Telegram API and the MTProto secure protocol via TDLib.
Other sources
Build instructions
Prerequisites
- Repository must be fetched via
git - JDK or Android Studio (with compatible bundled JDK)
- At least 8GB of RAM
- At least 7,32GB of free disk space when cloning with
--shallow-submodules --depth=1 - At least 2-5x times more disk space for files generated during build process.
macOS
- Homebrew
- git with LFS:
$ brew install git git-lfs && git lfs install - JDK:
$ brew install openjdk@25 - rustup, then Rust of
version.rustofversion.propertieswith targets of Android:$ scripts/setup-rust.sh, which printsrust.dirforlocal.properties
Ubuntu
- git with LFS:
# apt install git git-lfs - Run
$ git lfs installif you just installedgit-lfs - JDK:
# apt install openjdk-25-jdk - rustup:
# apt install rustup, then Rust ofversion.rustofversion.propertieswith targets of Android:$ scripts/setup-rust.sh, which printsrust.dirforlocal.properties. Run it again after a change ofversion.rust - If multiple JDK versions are installed:
# update-java-alternatives --list# update-java-alternatives --set java-1.25.0-openjdk-amd64(or other compatible version)
Windows
- MSYS2 (UCRT64 environment)
- Update packages:
pacman -Syu - Run
pacman -S --needed git mingw-w64-ucrt-x86_64-git-lfs perl make diffutils - Run
git lfs install - Run
git config --global core.longpaths true - rustup, then Rust of
version.rustofversion.propertieswith targets of Android:scripts/setup-rust.sh, which printsrust.dirforlocal.properties - Clone the repository
- Set
msys2.dirinlocal.propertiesafter cloning - Note: you have to use
\\or/as path separator in properties files
Building
$ git clone --recursive https://github.com/TGX-Android/Telegram-X tgx- In case you forgot the
--recursiveflag,cdintotgxdirectory and run:$ git submodule update --init --recursive - Open project via Android Studio or build manually from the command line:
./gradlew assembleLatestDebug - If build fails, follow the instructions provided in the error message.
Publishing
- Obtain Telegram API credentials
- Create
local.propertiesfile in the root project folder using any text editor:# Location where you have Android SDK installed sdk.dir=YOUR_ANDROID_SDK_FOLDER # Home of rustup with Rust of version.rust, printed by scripts/setup-rust.sh rust.dir=YOUR_RUSTUP_HOME_FOLDER # Telegram API credentials obtained at previous step telegram.api_id=YOUR_TELEGRAM_API_ID telegram.api_hash=YOUR_TELEGRAM_API_HASH
- Setup Firebase and replace
google-services.jsonwith the one that's suitable for yourapp.id
Commands
Reference of commands for building and maintenance
-Pabi limits native libraries to given ABIs, separated by commas: arm64, arm32, x64 or x86. Without it, all ABIs are built. Latest in task names can be replaced with another flavor.
Building
Set up Android SDK, NDK and local.properties, on Windows in MSYS2:
scripts/setup.sh
Check that submodules and Git LFS files are fetched:
./gradlew :app:validateGitSetup
Build and install debug build on connected device:
./gradlew :app:installLatestDebug -Pabi=arm64
Build legacy flavor for Android 4.x, which requires older NDK:
./gradlew :app:assembleLegacyDebug -PuseLegacyNdk=true -Pabi=arm32
Build libvpx, FFmpeg and tlottie for all flavors and ABIs, add -PuseLegacyNdk=true for legacy flavor:
./gradlew :app:buildLibvpx
./gradlew :app:buildFfmpeg
./gradlew :app:buildTlottie
Builds of tlottie for arm64-v8a are optimized by the profile of its drawing, app/jni/tlottie/arm64-v8a.profdata. After updates of tlottie or Rust, builds warn that it doesn't match, and it's made again from animated stickers and emoji on a connected device of the ABI, see GenerateTlottieProfileTask:
ANDROID_SERIAL=<device> ./gradlew ":app:generateTlottieProfile[arm64-v8a]" -Ptlottie.samples=<samples>
Reproducing public builds
In order to verify that there is no additional source code injected inside official APKs, you must use one of the following versions of Ubuntu:
- 21.04: for builds published before 26th May 2023
- 22.04.2 LTS: for builds published before 27th September 2025
- 24.04 LTS: for builds published before 1st October 2026
- 26.04 LTS: for any newer releases
And update its configuration:
- Create user called
vkwith the home directory located at/home/vk - Clone
tgxrepository to/home/vk/tgx - Check out the specific commit you want to verify
- In rare cases of builds that include unmerged pull requests, you must follow actions performed by Publisher's
fetchPrandsquashPrtasks cdintotgxfolder and install dependencies:# apt install $(cat reproducible-builds/dependencies.txt), then Rust with its targets of Android byscripts/setup-rust.shas in the requirements above- Follow up the build instruction from the previous section
- Run
$ apkanalyzer apk compare --different-only <remote-apk> <reproduced-apk> - If only signature files and metadata differ, build reproduction is successful.
Verifying side-loaded APKs
If you downloaded Telegram X APK from somewhere and would like to simply verify whether it's an original APK without any injected malicious source code, you need to get checksum (SHA-256, SHA-1 or MD5) of the downloaded APK file and find whether it corresponds to any known Telegram X version.
In order to obtain SHA-256 of the APK:
$ sha256sum <path-to-apk>on Ubuntu$ shasum -a 256 <path-to-apk>on macOS$ certutil -hashfile <path-to-apk> SHA256on Windows
Once obtained, there are three ways to find out the commit for the specific checksum:
- Sending checksum to
@tgx_bot - Searching for a checksum in
@tgx_log. You can do so without need in installing any Telegram client by using this URL format:https://t.me/s/tgx_log?q={checksum}(click to see in action). Note: unpublished builds cannot be verified this way.
License
Telegram X is licensed under the terms of the GNU General Public License v3.0.
For more information, see LICENSE file.
License of components and third-party dependencies it relies on might differ, check LICENSE file in the corresponding folder.
Third-party dependencies
List of third-party components used in Telegram X can be found here. Additionally you can check the specific commit of the third-party component used, for example, here and here.
Contributions
Telegram X welcomes contributions. Check out pull request template, code style and guide for contributors to learn more about Telegram X internals before creating the first pull request.
If you are a regular user and experience a problem with Telegram X, the best place to look for solution is Telegram X chat — a community with over 4 thousand members. Please do not use this repository to ask questions: if you have general issue with Telegram, refer to FAQ or contact Telegram Support.
