← Back to DrKLO/Telegram

How to Deploy & Use DrKLO/Telegram

Telegram for Android - Deployment & Usage Guide

Prerequisites

  • Android Studio: Version 3.4 or newer (must use "Open" not "Import")
  • Android NDK: Revision 20 specifically
  • Android SDK: API Level 27 (Android 8.1) minimum
  • Java JDK: 8 or 11 (compatible with Android Gradle Plugin)
  • Git: For source code management
  • Telegram API Credentials: Valid api_id and api_hash from my.telegram.org
  • Firebase Account: Access to Firebase Console
  • Release Keystore: For production APK signing (generate via keytool if needed)

Installation

1. Clone Repository

git clone https://github.com/DrKLO/Telegram.git
cd Telegram

2. Prepare Signing Keystore

Generate a release keystore (if you don't have one):

keytool -genkey -v -keystore release.keystore -alias telegram -keyalg RSA -keysize 2048 -validity 10000

Copy your release keystore to the config directory:

cp release.keystore TMessagesProj/config/

3. Configure Firebase

  1. Go to Firebase Console
  2. Create a new project (or use existing)
  3. Add two Android apps:
    • App 1: Package name org.telegram.messenger
    • App 2: Package name org.telegram.messenger.beta
  4. Enable Firebase Cloud Messaging for both
  5. Download google-services.json for each app
  6. Copy both JSON files to TMessagesProj/ (root of the module, same level as build.gradle)

Configuration

1. Gradle Properties

Edit gradle.properties (project root) and add your keystore credentials:

RELEASE_KEY_PASSWORD=your_key_password
RELEASE_KEY_ALIAS=your_alias_name
RELEASE_STORE_PASSWORD=your_store_password

2. Build Variables

Edit TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java and fill in your API credentials:

public static int APP_ID = your_api_id; // From my.telegram.org
public static String APP_HASH = "your_api_hash"; // From my.telegram.org
// Fill other variables as indicated by comments in the file

Note: The repository contains dummy values for release.keystore, google-services.json, and placeholder values in BuildVars.java to support reproducible builds. You must replace these with your own files before publishing.

3. Security Compliance

Review Telegram Security Guidelines before handling user data. Ensure your implementation follows MTProto protocol security requirements.

Build & Run

Debug Build (Development)

  1. Open Android Studio
  2. Select File > Open (do NOT use Import)
  3. Navigate to the cloned Telegram directory and click OK
  4. Wait for Gradle sync to complete
  5. Select build variant: debug (org.telegram.messenger.beta)
  6. Click Run (▶) or use:
./gradlew TMessagesProj:assembleDebug

APK output: TMessagesProj/build/outputs/apk/debug/

Release Build (Production)

./gradlew TMessagesProj:assembleRelease

APK output: TMessagesProj/build/outputs/apk/release/

Important: Before distributing:

  • Verify you've replaced the dummy release.keystore in TMessagesProj/config/
  • Confirm google-services.json contains your Firebase credentials
  • Ensure BuildVars.java contains your production API keys

Deployment

Distribution Requirements

Per Telegram's terms:

  • Do not use the name "Telegram" for your app without making it clear it's unofficial
  • Do not use the standard Telegram logo (white paper plane in blue circle)
  • Publish your source code to comply with the license
  • Maintain user privacy per security guidelines

Deployment Options

Direct APK Distribution:

./gradlew TMessagesProj:assembleRelease
# Distribute TMessagesProj/build/outputs/apk/release/*.apk

Google Play Store:

  1. Build signed release APK (see above)
  2. Ensure package name is changed from org.telegram.messenger if publishing as a separate app
  3. Upload to Play Console with your signing key

Firebase App Distribution (Beta Testing): Upload the beta variant (org.telegram.messenger.beta) to Firebase for internal testing.

Reproducible Builds

To verify build reproducibility:

  1. Use the exact NDK revision 20
  2. Keep the same Gradle and Android Studio versions
  3. Document all build environment specifics

Troubleshooting

Gradle Sync Failures

Issue: Could not find google-services.json Solution: Ensure google-services.json is in TMessagesProj/ directory, not the project root.

NDK Version Mismatch

Issue: No toolchains found in the NDK toolchains folder Solution:

  • Download NDK r20 specifically from Android Studio SDK Manager
  • Set ndk.dir in local.properties to the r20 path

Signing Errors

Issue: Keystore file not found for signing config 'release' Solution:

  • Verify release.keystore exists in TMessagesProj/config/
  • Check gradle.properties contains correct passwords and alias

Firebase Configuration

Issue: FirebaseApp with name [DEFAULT] doesn't exist Solution:

  • Confirm you created both package IDs (org.telegram.messenger and org.telegram.messenger.beta) in Firebase
  • Verify google-services.json contains both app configurations

API ID Errors

Issue: API_ID_INVALID or connection failures Solution:

  • Verify APP_ID in BuildVars.java is an integer, not a string
  • Ensure APP_HASH matches the hash provided at my.telegram.org for that API ID
  • Check that you're using the correct API credentials for debug vs. production

Build Variants

Issue: Cannot install debug and release simultaneously Solution: This is expected. The debug build uses org.telegram.messenger.beta package name while release uses org.telegram.messenger. Uninstall one before installing the other, or change the applicationId in build.gradle for testing.