How do I troubleshoot monitoring problems with my Android apps?
Find out how to solve problems related to Android mobile app monitoring.
OneAgent for Android
There can be multiple reasons for this problem:
- Verify if you used the correct property values that are provided by your monitoring application
- Did you adapt the
Network Security Configuration
correctly? You have to include system CA certificates or the certificate to your public Managed Security Gateway. - Check if Dynatrace or your public Managed Security Gateway is reachable from within your company network.
- Dynatrace Managed: Does the public Managed Security Gateway have a valid certificate?
No. For efficiency, Dynatrace does not accept monitoring data older than 10 minutes.
OneAgent for Android truncates most (user-related) values, if they exceed the border limit value of 250.
OneAgent for Android uses the default log framework from Android. You can use the logcat monitor from Android Studio or the command-line tool logcat to view these log lines.
Manual instrumentation
By default, OneAgent for Android assigns the WebRequestTiming
object to the last action. To use other action, tag the web request before you create the WebRequestTiming
object. The following example (see point 2a
and 2b
) shows how you can assign the WebRequestTiming
object to the webAction
variable instead of the otherAction
variable.
HttpURLConnection conn = null;
WebRequestTiming timing = null;
// [1] First, create an action
DTXAction webAction = Dynatrace.enterAction("time service");
DTXAction otherAction = Dynatrace.enterAction("dummy action");
try {
URL url = new URL("http://myhost.mydomain.com/TimeService?tz=CET");
conn = (HttpURLConnection) url.openConnection();
// [2a] Select your own action
webAction.tagRequest(connection);
// [2b] Use the existing tag and return the WebRequestTiming object
timing = Dynatrace.getWebRequestTiming(conn);
// [3] Call startWebRequestTiming() to begin the timing, and then handle the input
// stream from the connection
timing.startWebRequestTiming();
InputStream stream = new BufferedInputStream(conn.getInputStream());
readStream(stream);
// [4] Once done reading, timing can stop
timing.stopWebRequestTiming();
} catch (Exception e) {
// Attach the exception to the action
webAction.reportError("Exception", e);
// user-defined exception handling
} finally {
// [5] Lastly finalize the timing and the action in the finally block.
// This allow us to receive timings and close the action even if there is an
// exception thrown
if (timing != null) {
timing.stopWebRequestTiming();
}
webAction.leaveAction();
if (conn != null) {
conn.disconnect();
}
}
The Dynatrace.jar
library contains an dependency to the Apache HTTP client library. You must add the compile-time dependency for this library to your build.gradle
file.
android {
useLibrary 'org.apache.http.legacy'
}
Auto-instrumentation
Yes, all frameworks based on OkHttp 3
are supported.
No. Using DexGuard with the default configuration generates a protected APK file that the auto-instrumentor can't modify. The auto instrumentation process fails because the Unicode characters introduced by DexGuard are not supported. A possible workaround for this issue is to use -classobfuscationdictionary empty.txt
, where empty.txt
is an empty file. This option instructs DexGuard to assign obfuscated class names such as a
, b
, or c
, avoiding the Unicode class name issue.
You may have to deactivate additional protection and optimization features from DexGuard to generate an APK file that is compatible with the auto-instrumentor. If you do not want to modify you DexGuard configuration, then use manual instrumentation. Manual instrumentation is fully compatible with DexGuard or other protection tools.
No, the auto-instrumentor cancels the auto-instrumentation process, if the APK file is already auto-instrumented. You must use an uninstrumented APK file. You can run the auto-instrumentation process on a manually instrumented APK file.
No, this is not supported. Generally, manual and auto instrumentation must use the same OneAgent for Android version.
Only activities defined and enabled in AndroidManifest.xml
are instrumented.
Only web requests from a supported HTTP framework are captured. Check if your HTTP framework is in this list. If not, you must instrument your web requests manually.
OneAgent for Android only attaches web requests to a user action triggered within a specific time frame. The time frame starts when the action opens, and ends 500 ms
after the action closes. You can change this value with the DTXAutoActionTimeoutMilliseconds
property.
MenuItems:
- getTitle()
Other views:
view.getContentDescription()
if not null.getText()
for a TextView (or subclass of).- For
LinearLayout
the name is determined by looking at the children. - The class name is used as backup.
There can be multiple reasons why OneAgent for Android can't create a user action:
- The UI component is defined in a WebView.
- The listener method is defined in a resource XML file.
- The UI component uses an unsupported listener. The User action monitoring section in Auto-instrumentation for Android lists all supported listeners.
Enable the DTXSendEmptyAutoAction
property if your user interaction does not trigger a web request or lifecycle change. OneAgent for Android discards empty user actions by default.
You may be running your application in development or testing mode (not signed and deployed to Google Play) with a Google Maps release API key.
Yes. The instrument.sh
and instrument.cmd
files have a default maximum heap (-Xmx
) setting. If you experience an out-of-memory exception, you can increase the memory by updating that setting.
When the crash happens at the app startup phase on devices with Android 4.4 or lower, the mentioned class is not part of the primary .dex
file. Update the DTXMultiDexKeep
and/or DTXMultiDexKeepFile
property to resolve the issue. See Using multiple .dex files for Android instrumentation for details.
These exceptions are trigger by the Apktool tool and aapt
. They indicate that the auto-instrumentor wasn't able to read/modify the binary files of your APK file.
These tools are shipped within the Mobile Agent zip file and are regularly updated through public updates. Therefore, you should always use the latest OneAgent for Android version.
If your app depends on a framework file from a manufacturer that is not part of the standard Android OS, then you manually have to install this framework file with the Apktool
. You can find the install command in the official Apktool documentation. In this case the auto-instrumentor is not able to successfully update the 1.apk
. Normally the auto-instrumentor takes care of renewing the framework APK by deleting the framework directory and recreating the 1.apk
file using the Apktool
tool. However the Apktool
will not clean its framework directory if more than just the 1.apk
are installed. In this case you must update the 1.apk
manually.
The provided APK file contains an old mobile agent. When you use a combination of manual and auto-instrumentation, you can't mix the OneAgent for Android versions.
You are using a resource from Android that is not part of the public.xml
file. Instead of referring to a non-public resource, you should copy the resource into your application and refer it directly, as recommended here.
The auto-instrumentor uses the tool Apktool
and this tool blocks non-public resources for safety reasons.
The auto-instrumentor uses tools like aapt
and Apktool
to extract information from the AndroidManifest.xml
file and to modify it. In this case the tools are not able to generate a compiled version of the modified AndroidManifest.xml
file. The exact error message is only shown, when the DTXLogLevel
property is enabled.
These tools are shipped within the OneAgent for Android zip file and are regularly updated through public updates. Therefore, you should always use the latest OneAgent for Android version.
The provided APK file is already auto-instrumented and can't be auto-instrumented again. You must use an uninstrumented APK file.
he auto-instrumentor uses the tool Apktool (and aapt
) to unpack and decode the provided APK file. The exact error message is only shown, when the property DTXLogLevel
is enabled.
These tools are shipped within the OneAgent for Android zip file and are regularly updated through public updates. Therefore, you should always use the latest OneAgent for Android version.
If your app depends on a framework file from a manufacturer that is not part of the standard Android OS, then you manually have to install this framework file with the Apktool
. You can find the install command in the official Apktool documentation. In this case the auto-instrumentor is not able to successfully update the 1.apk
. Normally the auto-instrumentor takes care of renewing the framework APK by deleting the framework directory and recreating the 1.apk
file using the Apktool
tool. However the Apktool
will not clean its framework directory if more than just the 1.apk
are installed. In this case you must update the 1.apk
manually.
You have to adjust the default value of the DTXPrimaryDexLimit
property. read more details in What do I have to consider for Android multidex applications? for details.
Dynatrace Gradle plugin
There can be multiple reasons for this error message:
- Not specifying the
applicationId
or other mandatory properties. - Not adding a configuration block (
dynatrace
) to your module'sbuild.gradle
file. - Not defining a configuration for your product flavor and also not adding a default configuration.
Check if you have added the buildscript
block with the classpath 'com.dynatrace.tools:android:+'
dependency to your module's build.gradle
file.
Gradle was not able to find the specified version. Check if you have specified the correct version number. You can check the available version on JCenter and Maven Central. You also must add jcenter()
or mavenCentral()
to your buildscript
configuration.
Gradle was not able to find a version that matches your version settings. You can check the available version on JCenter and
Maven Central. You also have to add jcenter()
or mavenCentral()
to your buildscript
configuration.
Check if you have applied the Dynatrace Gradle plugin before the dynatrace
block and the dynatrace.agent()
dependency.
apply plugin: 'com.dynatrace.tools.android'
dynatrace {
...
The Dynatrace Gradle plugin started the auto-instrumentation, but it failed. Check the error message from the auto-instrumentor for further help.
The Dynatrace Gradle plugin auto-instrumented your APK file, but was not able to successfully extract your signing information and sign the instrumented APK file with your certificate. Check if your Dynatrace plugin version fits the used Android plugin version.
Because auto-instrumentation was successful, you can use the generated instrumented APK in the <project>/<module>/build/outputs/apk/<app_name>/dist
folder. You must sign the <app_name>.apk
file manually with your Google playstore certificate.
You have added the OneAgent for Android library multiple times. Check if you have added the Dynatrace.jar
to your libs directory and remove it. See the section Enable manual API calls to enrich mobile-user experience data of the Dynatrace Gradle plugin for more information on how to integrate manual instrumentation into your build process.
The log file is stored in the <project>/<module>/build/tmp/autoInstrument<build_variant>/logs
directory.
For version 2.2 and later of the Android Gradle plugin, the Dynatrace Gradle plugin generates an uninstrumented APK file with a file suffix of _uninstrumented
. In some cases it can be useful to have an uninstrumented version of the application, for example if you notice that OneAgent for Android interferes with another library. If you use manual instrumentation, then the manual instrumentation is still part of the _uninstrumented
APK file.
Check if you have uploaded the correct file: <project>/<module>/build/outputs/apk/<app_name>.apk
. Do not use the APKs in the
<project>/<module>/build/outputs/apk/<app_name>/dist
directory, because they are unsigned or signed with a debug certificate.