Error descriptions

The following sections describe common errors that you might encounter while working with the AppMetrica SDK on Android.

  1. Error when adding the library to a project
  2. Error initializing AppMetrica with third-party libraries
  3. Incorrect duration of user session during manual tracking
  4. High power consumption of the AppMetrica library

Error when adding the library to a project

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)

This error indicates that the method limit was exceeded at the DexIndexOverflowException stage of processing. We recommend reviewing the libraries used — perhaps they are very heavy. If they can't be replaced with lightweight alternatives, you can use multiple DEX files. This might increase the app loading time.

Error initializing AppMetrica with third-party libraries

If you encounter an initialization error after integrating a third-party library (such as Firebase Cloud Messaging), make sure that the third-party component is initialized in the main process.

The error text may be as follows:

Unable to create application your.package.name.YourApp: java.lang.IllegalStateException:
Default FirebaseApp is not initialized in this process your.package.name:Metrica. Make sure to call FirebaseApp.initializeApp(Context) first.

Add verification of the main process before initializing third-party libraries. For example:

class MyApplication extends Application {

  @Override
  public void onCreate() {
    if (isMainProcess()) {
        // Initializing third-party libraries after verification.
    }
  }
}
Note. Implement verification of the main process on your own.

Incorrect duration of user session during manual tracking

If the manual tracking of the user session is incorrectly implemented, it may lead to an inaccurate determination of its duration.

If the user session duration data doesn't look correct, make sure that when the user session ends, the YandexMetrica.pauseSession() method is always called. If this method is not called, the library assumes that the session is active and continues to exchange data with the server part of AppMetrica.

It is recommended to check the duration of the session timeout. It is specified with the withSessionTimeout() method. The timeout specifies the time interval during which the session will be considered active even after the application is closed.

High power consumption of the AppMetrica library

If there is the increased power consumption of the library, make sure that when the user session ends, the YandexMetrica.pauseSession() method is always called. If this method is not called, the library assumes that the session is active and continues to exchange data with the server part of AppMetrica.

It is recommended to check the duration of the session timeout. It is specified with the withSessionTimeout() method. The timeout specifies the time interval during which the session will be considered active even after the application is closed.