28 Mar 2023 01:04 PM
In a mobile app with the client we have installed the gradle plugin.
In dependencies we are using this import
classpath 'com.dynatrace.tools.android:gradle-plugin:8.+'
We are able to import these packages:
import com.dynatrace.android.agent.Dynatrace
import com.dynatrace.android.agent.conf.DataCollectionLevel
import com.dynatrace.android.agent.conf.UserPrivacyOptions
We are unable to resolve the following import on the client build.
import com.dynatrace.android.api.privacy.MaskingConfiguration;
Are there any additional dependency classpath's needed for the privacy imports?
Solved! Go to Solution.
28 Mar 2023 03:21 PM
Hey Conal_Buchanan1,
The Dynatrace Android Gradle plugin automatically adds the Session Replay library as dependency, when it is enabled via the plugin configuration. Is the following snippet part of your plugin configuration?
sessionReplay.enabled true
You also have to press the "Gradle Sync" button in Android Studio to update the dependencies for the IDE.
29 Mar 2023 10:14 AM
Hi,
Thanks, that confirms there are no additional dependencies.
The snippet is there.
I sat with the developer as he re-synced the gradle, ran and crashed the app.
There is a session replay although there is an error.
After syncing the gradle we added the imports back but they still do not resolve.
29 Mar 2023 12:10 PM
The Dynatrace Android Gradle plugin only modifies the dependency of the application module "app". The class DynatraceUtilities is part of the library module "va_base", which is not modified by the plugin. I assume that you manually added a dependency for the OneAgent library, because the IDE recognizes the "applyUserPrivacyOptions" method call.
Normally the masking logic is added to the application class which is part of the application module. This is the recommended approach by Dynatrace and supported by the Dynatrace Android Gradle plugin. In your case, you have to also add a dependency for the correct Session Replay library to the module "va_base".
Because of potential privacy concerns, the plugin only adds the Session Replay library to variants where session replay is enabled. For the other variants a dependency for the no-op version (= empty library) is added, to ensure customers that there is no screenshot capability available.
To avoid library conflicts, you have to setup the dependency based on your plugin configuration.
If you need help for this task, you can share your plugin configuration and we will help you to define the dependencies correctly.
06 Apr 2023 08:11 AM
I requested that we add a dependency to the va_base gradle or move the DynatraceUtilities class but this didn't resolve the issue.
This is the structure of the top level gradle.
buildscript {
ext {
dynatraceVersion = '8.261.2.1013'
}
dependencies {
classpath "com.dynatrace.tools.android:gradle-plugin:$dynatraceVersion"
}
}
apply from: 'dynatrace-config.gradle'
subprojects {
pluginManager.withPlugin("com.android.library") {
dependencies {
implementation com.dynatrace.tools.android.DynatracePlugin.agentDependency()
}
}
}
Here the subprojects clause might be adding the dependency code for the "applyUserPrivacyOptions" method call but not "MaskingConfiguration"?
06 Apr 2023 12:26 PM
The provided snippet adds a dependency to the OneAgent for Android library to all library modules:
subprojects {
pluginManager.withPlugin("com.android.library") {
dependencies {
implementation com.dynatrace.tools.android.DynatracePlugin.agentDependency()
}
}
}
Therefore the "applyUserPrivacyOptions" method is available in the module "va_base". The Session Replay feature is part of another artifact and therefore you have to manually configure an additional dependency to this artifact in the "va_base" library module.
Dynatrace provides two different artifact versions for the Session replay feature. Depending on your plugin settings you have to either add the regular Session Replay artifact with the artifact id "android-replay-agent" or the "no operation" version with artifact id "android-replay-agent-noop". This approach is needed because some customer do not want to have the screenshot capability in their applications, when they do not use Session Replay.
An example: If you have Session replay enabled in "debug", but disabled in "release", you need the following configuration:
dependencies {
// contains Session Replay feature
debugImplementation("com.dynatrace.agent:android-replay-agent:<version>")
// empty library to avoid compile errors
releaseImplementation("com.dynatrace.agent:android-replay-agent-noop:<version>")
}
13 Apr 2023 12:34 PM
Seems this resolved the dependency.
Thanks!