Uploading mapping and SO files on Android
To reduce the size of an app, you can compress and obfuscate the code during a release build. In this case, information about crashes will be sent in an obfuscated form. It's difficult to extract data for analysis from these crash logs. To analyze crash logs, upload the mapping or SO file to AppMetrica.
To upload mapping and SO files to AppMetrica, use the crash plugin. It automatically uploads mapping and SO files when building an app.
Enabling the plugin
To enable the plugin:
- Add the following dependency to the build.gradle root file:
buildscript { ... dependencies { ... classpath 'com.yandex.android:appmetrica-build-plugin:0.2.1' } }
Copied to clipboard - 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. ndk { // Optional. enable = { applicationVariant -> true } soFiles = { applicationVariant -> listOfSoFiles } // Optional. additionalSoFiles = { applicationVariant -> listOfSoFiles } // Optional. } } ...
Copied to clipboardpostApiKey
*enable
Lambda function that acceptsApplicationVariant
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 forbuildType = 'release'
.Note. Use one of the parameters to specify assembly types:enable
ormappingBuildTypes
.mappingBuildTypes
ThebuildType
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
ormappingBuildTypes
.offline
Enables the
offline
mode.Boolean
or a lambda function that takesApplicationVariant
.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
.ndk
This parameter is required for loading characters from the SO file to track native crashes.
enable
Lambda function that accepts
The default value isApplicationVariant
and returns whether to load the characters from the SO files for this build option.false
.soFiles
Lambda function that accepts
ApplicationVariant
and returns a list of SO files.By default, the plugin searches for SO files in the Android Studio project folders.
You need to redefine the path if your SO files are in an unusual location or the plugin can't find them.
additionalSoFiles
Lambda function that accepts
ApplicationVariant
and returns a list of additional SO files to load the characters from.* Required
Manual loading
To load manually, enable and use the plugin in offline
mode. This is necessary to link the mapping file to the app build.
- In the app/build.gradle file, turn on
offline
mode and run the build.appmetrica { ... offline = true }
Copied to clipboardoffline
Enables offline mode. Acceptable values:true
— Doesn't upload the mapping file to AppMetrica. If enabled, it outputs the archive path to the log after the build is complete.false
— Automatically uploads the mapping file.
The default value is
false
. - In the AppMetrica interface, go to the app settings from the menu on the left.
- Open.
- Click Choose file and upload the ZIP archive.