How the AppMetrica library works

The AppMetrica library consists of two parts: the client and the service. You should take their features into account during initialization:

  • Client part: Pre-validates data and transmits it to the service part. An instance of the client part is created for each process in the application.

  • Service part: It is responsible for storing data and sending it to the server. The service runs in the main application process. Therefore AppMetrica SDK saves the crash report to a file and sends them the next time it is run.

Recommendations for initialization

  • If the application has multiple processes where you want to use AppMetrica, initialize the library with the same configuration for each process. Otherwise, the configuration may depend on which of the processes starts first.

    You can use reporters for sending data. They can be initialized with different configurations. For more information, see Sending statistics to an additional API key.

  • Initialize the AppMetrica library in the Application.onCreate() method. As a result, the library will be initialized within each process.

  • Keep in mind that the ContentProvider instance is created before the Application instance. If you initialize the library in the Application.onCreate() method, you can't send data from the ContentProvider.onCreate() method.

  • Don't add the code to the Application.onCreate() method that should not be executed more than once. Run this code when creating other components, or run it in a separate Service.

  • Avoid long-term operations in the Application.onCreate() method and do not initialize other libraries in it. The execution time of this method directly affects the opening speed of the first Activity, Service, or Receiver.

Learn more

If you didn't find the answer you were looking for, you can use the feedback form to submit your question. Please describe the problem in as much detail as possible. Attach a screenshot if possible.

Contact support