Plugin for mapping files uploading

AppMetrica lets you collect and analyze information about app crashes in the Crashes report. For more information, see Crashes.

Information about crashes on Android can be sent in an obfuscated form. It's difficult to extract data for analysis from these crash logs. For crash logs to be analyzed, you need to upload the mapping file to AppMetrica: automatically during the app assembling or manually via the web interface.

To download mapping files automatically during assembly, you need to enable the AppMetrica Build Plugin.

  1. Enabling the plugin
  2. Build errors
  3. Changelog

Enabling the plugin

Attention. To use the plugin, you need to install the AppMetrica SDK with version 3.8.0 or higher.

To enable the plugin:

  1. Add the following dependency to the build.gradle root file:
    buildscript {
        ...
        dependencies {
            ...
            classpath 'com.yandex.android:appmetrica-build-plugin:0.1.2'
        }
     }
    Copied to clipboard
  2. Add the following to the app/build.gradle file:
    ...
    apply plugin: 'appmetrica-plugin'
    
    appmetrica {
        postApiKey = { applicationVariant -> "Post Api key for variant" }
        // or postApiKey = "Post Api key"
        enable = { applicationVariant -> true }    // Optional.
        mappingBuildTypes = ['release']            // Optional.
        offline = false                            // Optional.
    }
    ...
    Copied to clipboard
    postApiKey *
    Post API key or lambda function that returns a Post API key for ApplicationVariant. Read more about ApplicationVariant in the Android and Javadoc documentation.

    You can get the Post API key in the AppMetrica Settings. It's used to identify your app.

    If offline = true, the parameter is optional.

    enable
    Lambda function that accepts ApplicationVariant and returns whether to use the plugin for this build option.

    If the plugin is not used, apk does not change and the mapping file does not load.

    By default, it returns true only for buildType = 'release'.

    Note. Use one of the parameters to specify assembly types: enable or mappingBuildTypes.
    mappingBuildTypes
    The buildType list that the mapping file is sent for.

    Default value: ['release'].

    To disable the uploading of mapping files for a specific type of build, delete that buildType from the list.

    Note. Use one of the parameters to specify assembly types: enable or mappingBuildTypes.
    offline

    Enables the offline mode. Boolean or a lambda function that takes ApplicationVariant.

    Acceptable values:

    • true — Doesn't upload a file to AppMetrica. If enabled, it outputs the archive path to the log after the build is complete. You can upload it manually via the web interface.
    • false — Automatically uploads the mapping file.

    The default value is false.

    Required

Build errors

Possible errors during a build:

  • IllegalStateException — Enable code obfuscation using ProGuard or R8 Compiler.
  • HttpResponseException — Check your internet connection.

Changelog

Version 0.1.2

Released 13 March 2020

  • Fixed a crash during configuration process if the Post API key is not specified. There is a check during the boot run.
  • Fixed the way to get mapping files.
  • Added information about an error during uploading mapping files.
  • Added the ability to specify custom plugin parameter values for different ApplicationVariant.

Version 0.0.1

Released 8 October 2019