Telegram of import project, a preliminary understanding

1, download the source code, imported Android studio in commissioning and successful operation

From available on the github source code to debug successful, Telegram can be installed on phones running back and forth spent at least forty-five days! Debugging process encountered many problems, hereby record!

Correct steps:

  • By cloning source github. Address: Telegram source . Accordance with the requirements Download Android studio 3.4 and above, NDK20, SDK8.1 on the web site, to avoid an error. The figure is the cloning process, of course, also be operated by a command line git.


    Problems encountered: Clone failed polyclonal several times, with the git graphical interface version, the ultimate success. It may be a network problem. Also can not git clone direct download compressed, using Android studio open the folder.
  • Generate release.keystore placed in the project directory (Telegram \ TMessagesProj \ config). This is because the clone from github, would be less grams of some configuration files, so you want to generate their own. For how to generate release.keystore files, you can look at this . key store path may select a path directly above. Name written as release.keystore. (Key store password, alias, key password remember well, and so on down to gradle.properties to fill in)

    Note: The generated keystore file name suffix .jks, need to rename release.keystore. Debugging process, if an error contained release.keystore keywords appear, usually this step is where the problem. If the file exists try to view the directory, or regenerate, and check gradle.properties parameters are correct.
  • Fill RELEASE_KEY_PASSWORD, RELEASE_KEY_ALIAS and RELEASE_STORE_PASSWORD in gradle.properties in order to access their release.keystore.
  • Click here to create applications with two android application, org.telegram.messenger and org.telegram.messenger.beta, and download org.telegram.messenger of google-services.json, copied to TMessagesProj subdirectory.

    Encountered a problem: Run error, lack org.telegram.messenger.beta package, try to applicationIdSuffix ".beta" This code appears in build.gradle commented.
  • Fill in the values in TMessagesProj / java / org / telegram / messenger / BuildVars.java in - each variable has a link to display data acquired from where and from where. APP_ID, APP_HASH FIG register obtained by the method, and the following four parameters can be the same as I, wherein HOCKEY_APP_HASH and as long as 32 to HOCKEY_APP_HASH_DEBUG.


    Problems encountered, several pages open, some of these sites require over the wall to access this resolve itself.
  • In this case, the necessary steps have been completed, began to compile and run. This process may encounter various problems, according to the actual situation rational analysis, online access solutions. Below stick out my Gradle configuration, SDK, NDK version, and the entire import process has some links to help on the project commissioning.



    Telegram error summary
    in Android Studio compile their own Telegram
    telegrm telegram FAQ
    Gradle build error: Received Status code 400 from Server: Bad Request
    Error: SSL the peer Shut Down incorrectly (perfect solution)
    No matching Client found for Package Penalty for name (Google Analytics) - multiple productFlavors & buildTypes [closed]

Note: After running successfully, you can connect your phone to run installation (virtual machine more cards, complete with my computer does not move), developers need to open the phone mode and Debug mode.

2, Telegram project directory structure

Different Telegram and general android project is that it is not a part of the front end ui layout xml file write, but with pure java to write! So you will find that the basic layout .xml file can not be found.

Currently, the code read part due before never learned basic android, looks more difficult. Some probably know the class is doing. Hereby record!

the messenger Directory:
ApplicationLoader.java -> is used to load configuration information to initialize the App, to monitor network changes.
Class> sends all kinds of messages - SendMessagesHelper

the directory ui:
ChatActivityEnterView.java -> This class is the interface portion sends a message in the chat window. There are buttons to send disappeared listen for events, as well as drawing and other related interface.
CacheControlActivity.java -> Cache Cleanup Activity
ChangeNameActivity.java -> Edit name entries Activity
ChatActivity.java -> chat window, there is a button to listen to events, the top navigation entry interface and monitor events.
DateSettingsActivity.java -> Data Storage Settings
LoginActivity.java -> login screen, select the country, fill in the phone number
DialogActivity.java -> after the successful landing, jump pages, dialog interface displays all session information.
LogoutActivity.java -> Logout interface
NotificatonsSettingsActivity.java -> notifications and sound Activity
PasscodeActivity.java -> add a password lock
PrivacySettingActivity.java -> Privacy, Security Settings
ThemeActivity.jav -> Chat Theme class
...

3, knowledge

  • Dynamic data access permissions, placed in the constructor Fragment, the problems that cause this Fragment can not be opened.
  • Byte stream, a character stream differences: In the end of the stream is a stream of bytes to the end of the reader and writer is a character stream, the difference is the time to read and write a byte is read, a character is based. Almost in actual use. In the read and write files need to deal with the contents of rows, such as comparing a particular character, a line of data processing when the general will choose a character stream. Just read and write files, file contents, and unrelated, usually selected byte stream. All files are byte hard disk or manner during transport, including pictures, etc. are stored in a manner byte, but only if the character is formed in the memory, so in development, bytes flow more widely used . Java byte stream: InputStream is the ancestor of all the bytes of the input stream, and OutputStream is the ancestor of all output stream of bytes. .Java character stream: Reader is a string input stream to read all of the ancestors, and writer is the ancestor of all the output string. InputStream, OutputStream, Reader, writer is an abstract class. It is not directly new.
Published 26 original articles · won praise 3 · Views 1482

Guess you like

Origin blog.csdn.net/Ydecube/article/details/102874289