cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Mobile monitoring library imports

Conal_Buchanan1
Participant

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?

 

6 REPLIES 6

Thomas_Wirth1
Dynatrace Champion
Dynatrace Champion

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.

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.

Conal_Buchanan1_1-1680081219585.png

 

After syncing the gradle we added the imports back but they still do not resolve.

Conal_Buchanan1_0-1680080718370.png

 

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.

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"?

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>")
}

 

Seems this resolved the dependency.

Thanks!

Featured Posts