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_idandapi_hashfrom my.telegram.org - Firebase Account: Access to Firebase Console
- Release Keystore: For production APK signing (generate via
keytoolif 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
- Go to Firebase Console
- Create a new project (or use existing)
- Add two Android apps:
- App 1: Package name
org.telegram.messenger - App 2: Package name
org.telegram.messenger.beta
- App 1: Package name
- Enable Firebase Cloud Messaging for both
- Download
google-services.jsonfor each app - Copy both JSON files to
TMessagesProj/(root of the module, same level asbuild.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)
- Open Android Studio
- Select File > Open (do NOT use Import)
- Navigate to the cloned
Telegramdirectory and click OK - Wait for Gradle sync to complete
- Select build variant:
debug(org.telegram.messenger.beta) - 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.keystoreinTMessagesProj/config/ - Confirm
google-services.jsoncontains your Firebase credentials - Ensure
BuildVars.javacontains 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:
- Build signed release APK (see above)
- Ensure package name is changed from
org.telegram.messengerif publishing as a separate app - 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:
- Use the exact NDK revision 20
- Keep the same Gradle and Android Studio versions
- 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.dirinlocal.propertiesto the r20 path
Signing Errors
Issue: Keystore file not found for signing config 'release'
Solution:
- Verify
release.keystoreexists inTMessagesProj/config/ - Check
gradle.propertiescontains correct passwords and alias
Firebase Configuration
Issue: FirebaseApp with name [DEFAULT] doesn't exist
Solution:
- Confirm you created both package IDs (
org.telegram.messengerandorg.telegram.messenger.beta) in Firebase - Verify
google-services.jsoncontains both app configurations
API ID Errors
Issue: API_ID_INVALID or connection failures
Solution:
- Verify
APP_IDinBuildVars.javais an integer, not a string - Ensure
APP_HASHmatches 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.