Crash plugin
This is an archived version of documentation. You can find the current documentation for all platforms here.
AppMetrica lets you collect information about native and Java crashes. You can analyze them in the Crashes report. See also Crashes/errors.
To reduce the size of an app, optimize the code during a release build.
If the code was compressed and obfuscated during the build of an Android application, information about crashes is transmitted in obfuscated form. To extract data for analysis from such crash logs, AppMetrica performs server-side deobfuscation.
To do this, upload the mapping files or debug symbols of SO files to AppMetrica, either automatically when building the app or manually via the web interface.
To send files, enable the AppMetrica Build Plugin.
Connecting 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.7.0' } }
Copied to clipboard - Add 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. mappingFile = { applicationVariant -> null } // Optional. enableAnalytics = true // Optional. ndk { // Optional. enable = { applicationVariant -> false } soFiles = { applicationVariant -> listOfSoFiles } // Optional. additionalSoFiles = { applicationVariant -> listOfSoFiles } // Optional. addNdkCrashesDependency = { applicationVariant -> true } // Optional. } } ...
Copied to clipboardpostApiKey
*enable
Lambda function that acceptsApplicationVariant
and returns whether to use the plugin for this build option.If the plugin isn't used, the
apk
doesn't change and the mapping file doesn't load.By default, it returns
true
only forbuildType = 'release'
.Note. Use one of the parameters to specify assembly types:enable
ormappingBuildTypes
.mappingBuildTypes
The list of build types,buildType
, for which the mapping file will be sent.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 acceptsApplicationVariant
.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
.mappingFile
A lambda function that accepts
The default value isApplicationVariant
and returns the mapping file to upload. If it returnsnull
, the default value is used.ApplicationVariant.mappingFileProvider
.enableAnalytics
Enables sending plugin usage statistics to AppMetrica.
Boolean
.Acceptable values:
true
— Sending statistics is enabled.false
— Sending statistics is disabled.
The default value is
true
.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.addNdkCrashesDependency
Lambda function that accepts
The default value isApplicationVariant
and returns whether to add a dependency onmobmetricalib-ndk-crashes
.true
.* Required
- If the
ndk
parameter is enabled, debug symbols are sent using the Gradle taskupload${variant.name.capitalize()}Symbols.
To call a task automatically, you can add it to a file app/build.gradle the following code:... afterEvaluate { android.applicationVariants.forEach { variant -> def uploadSymbolsTask = project.tasks.named("upload${variant.name.capitalize()}Symbols") if (uploadSymbolsTask != null) { variant.assembleProvider.get()?.finalizedBy(uploadSymbolsTask) // Если используете apk project.tasks.named("bundle${variant.name.capitalize()}").get()?.finalizedBy(uploadSymbolsTask) // Если используете aab } } } ...
Copied to clipboard
Manual loading
To manually load, 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, enable
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.
Build errors
Possible errors during a build:
IllegalStateException
— Enable code obfuscation using ProGuard or R8 Compiler.HttpResponseException
— Check your internet connection.
If you encounter further errors, please contact technical support.
Changelog
Version 0.7.0
Released April 19, 2023.
- Added more details to the error reporting that mapping files are missing.
- Added support for AGP up to version 7.4.+ and Gradle up to 7.5.
Version 0.6.2
Released July 28, 2022
- Improved performance of the plugin.
Version 0.6.1
Released May 20, 2022
- Improved performance of the plugin.
Version 0.6.0
Released May 17, 2022
- Added the mappingFile parameter.
- Fixed the Cannot query the value of this property because it has no value available error that occurred when trying to get a mapping file.
Version 0.5.0
Released April 21, 2022
- Fixed the IndexOutOfBoundsException: toIndex (16) is greater than size (8) raised when processing an SO file.
- Fixed the Cannot query the value of this property because it has no value available crash that occurred when using the flag.
- Added the ndk.addNdkCrashesDependency flag.
Version 0.3.0
Released June 17, 2021
- Added support for gradle 7.
- Added sending analytics.
Version 0.2.4
Released May 26, 2021
- Added support for AGP 4.2.0.
- Improved performance and stability of the plugin.
Version 0.2.2
Released February 19, 2021
- Fixed the
Connection timed out
error when loading mapping files or symbols and using a proxy.
Version 0.2.1
Released 3 November 2020
- Added support for Android App Bundle.Attention. Don't run the
apk
andaab
build with a single gradle command. This may lead to incorrect processing of crashes. - Added logging.
- Improved SO file search and parsing.
Version 0.1.3
Released 12 June 2020
- Added automatic loading of characters from the SO files to track native crashes.
- Added the
split_version_codes
field to the info.txt file to store every loadedversion_code
of the app.
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