Search code examples
androidbuildandroid-gradle-plugintelegram

Building the Telegram application on Android from source


For the first time I am compiling an application from source codes, I am reviving the version of Telegram 5.3.0 for Android.

Do I understand correctly that the build requires gradle version 4.8 and no other, as well as JDK version no higher than 8? Also, I don't have the reseale.keystore file, can I get this file from a newer version of the source code, or is this file created separately?

Project structure:

enter image description here


Solution

  • tldr: gradle wrapper is already set up, so you can just use whatever version it uses. JDK 8 is guaranteed to work, other version may or may not work. You need to create you own release.keystore, it is used for signing the app and sharing it poses severe security risks.

    Note: the closest version of Telegram sources I could find is 5.3.1, so I'll be using that for reference.

    Telegram at that version was set up with Gradle 4.4 and Android Gradle plugin 3.1.4. Looking at the Gradle-AGP compatibility AGP 3.1.4 requires Gradle 4.4+. So versions between 4.4 and 4.10.2 (the last 4.x release). Higher versions (5.x+) might work, but it is not guaranteed.

    Another point of consideration with AGP 3.1.4 is Android Studio compatibility. Arctic Fox | 2020.3.1 is the last version that supports AGP 3.1, so using new Studio versions will require AGP and possibly Gradle and JDK upgrades.

    Now about the JDK. Starting from Android Studio 2.2.0 it was bundled with JDK 8 and it was so until Android Studio 4.2.0 when it switched to JDK 11. Additionally Gradle 4.4 supports up to JDK 9 and Gradle 4.7 - up to JDK 10 (compatibility docs). So you don't really have many options besides using JDK 8.

    Finally the release.keystore. There's a good section in the docs on why it should be kept private. Basically it stores the keys used for signing the app. So anybody (e.g. a malicious actor) with access to the keystore can create a different app that will be treated by the OS as an update to the existing version. That's why Telegram's keystore is not public and you need to create your own.