# Mobile applications: Build issues with Dynatrace Android Gradle plugin

**URL:** <https://community.dynatrace.com/t/mobile-applications-build-issues-with-dynatrace-android-gradle-plugin/43692>\
**Category:** Troubleshooting\
**Tags:** real-user-monitoring-classic, android, mobile-monitoring\
**Created:** [January 21, 2024, 2:10pm UTC](https://community.dynatrace.com/t/mobile-applications-build-issues-with-dynatrace-android-gradle-plugin/43692 "2024-01-21T14:10:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![maliborskaya](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@maliborskaya](https://community.dynatrace.com/u/maliborskaya)\
**Post date:** [January 21, 2024, 2:10pm UTC](https://community.dynatrace.com/t/mobile-applications-build-issues-with-dynatrace-android-gradle-plugin/43692/1 "2024-01-21T14:10:00Z")

</div>

## Why do I see the message `OneAgent SDK version \<version_number\> does not match Dynatrace Android Gradle plugin version \<version_number\>`?

OneAgent SDK and the Dynatrace Android Gradle plugin must have the same version. You may have added OneAgent SDK (with a higher version) via a Gradle dependency to your Android application project.

## Why does my build fail with `Plugin with id com.dynatrace.instrumentation not found`?

Check if you’ve added the Dynatrace Android Gradle plugin to the build script classpath. See&nbsp;[Instrument your application via Dynatrace Android Gradle plugin](https://docs.dynatrace.com/docs/shortlink/dynatrace-android-gradle-plugin-first-steps)&nbsp;for detailed instructions.

## Why does my build fail with `Could not find com.dynatrace.tools.android:gradle-plugin:\<version_number\>`?

This is because Gradle was unable to find the specified version. Check if you’ve specified the correct version number. You can check the available version on Maven Central. You must also ensure that the Maven Central repository is declared. See&nbsp;[Instrument your application via Dynatrace Android Gradle plugin](https://docs.dynatrace.com/docs/shortlink/dynatrace-android-gradle-plugin-first-steps)&nbsp;for the detailed instructions.

## Why does my build fail with `Could not find any version that matches com.dynatrace.tools.android:gradle-plugin:\<version_number\>.+.`?

Gradle was unable to find a version that matches your version settings. You can check the available version on Maven Central. You must also ensure that the Maven Central repository is declared. See&nbsp;[Instrument your application via Dynatrace Android Gradle plugin](https://docs.dynatrace.com/docs/shortlink/dynatrace-android-gradle-plugin-first-steps)&nbsp;for the detailed instructions.

## Why does my build fail with `Could not get unknown property dynatrace for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler`?

Check if you’ve applied the Dynatrace Android Gradle plugin before the&nbsp;`dynatrace`&nbsp;/&nbsp;`configure<com.dynatrace.tools.android.dsl.DynatraceExtension>`&nbsp;block dependency. See&nbsp;[Instrument your application via Dynatrace Android Gradle plugin](https://docs.dynatrace.com/docs/shortlink/dynatrace-android-gradle-plugin-first-steps)&nbsp;for the detailed instructions.

**Groovy**

```markup
apply plugin: 'com.dynatrace.instrumentation'

dynatrace {
...
}

```

**Kotlin**

```markup
apply(plugin = "com.dynatrace.instrumentation")

configure<com.dynatrace.tools.android.dsl.DynatraceExtension> {
...
}

```

## Why does my build fail with `No configuration for the Dynatrace Android Gradle plugin found! Please copy the configuration block from the instrumentation wizard to the proper location.`?

You applied the Dynatrace Android Gradle plugin to your build file (top-level or module-level build file), but you didn’t provide a plugin configuration. Check&nbsp;[Instrument your application via Dynatrace Android Gradle plugin](https://docs.dynatrace.com/docs/shortlink/dynatrace-android-gradle-plugin-first-steps)&nbsp;to learn how to add the plugin configuration snippet.

For React Native apps, follow the troubleshooting instructions at&nbsp;[Dynatrace React Native Plugin documentation](https://www.npmjs.com/package/@dynatrace/react-native-plugin#troubleshooting-and-applicable-restrictions).

## Why do I see the message `Task printVariantAffiliation not found in project :\<module_name\>`?

Ensure that you’ve added the Dynatrace Android Gradle plugin to the build script classpath and applied the plugin. Check&nbsp;[Instrument your application via Dynatrace Android Gradle plugin](https://docs.dynatrace.com/docs/shortlink/dynatrace-android-gradle-plugin-first-steps)&nbsp;for the detailed instructions.

The Dynatrace Android Gradle plugin only generates new Gradle tasks (like the&nbsp;`printVariantAffiliation`&nbsp;task) for specific subprojects of your Android application project. It does not generate tasks for the root project and some subproject. For example, the Dynatrace Android Gradle plugin doesn’t generate the&nbsp;`printVariantAffiliation`&nbsp;for&nbsp;[Android library modules](https://docs.dynatrace.com/docs/shortlink/dynatrace-android-gradle-plugin-uncommon-architectures#library-modules).

## Why do I see the message `The Dynatrace Android Gradle Plugin can only be applied to Android projects`?

You can only use the Dynatrace Android Gradle plugin when your Android project is built with the Android Gradle plugin. This error message is displayed when the Dynatrace Android Gradle plugin is used in non-Android projects or in Android projects that are not built via the Android Gradle plugin.

## Why do I see the message `The Dynatrace Android Gradle plugin must be applied in the top-level build.gradle (or build.gradle.kts) file`?

The plugin with the&nbsp;`com.dynatrace.instrumentation`&nbsp;ID must be applied in the&nbsp;[top-level build file](https://dt-url.net/top-level-build-file)&nbsp;file. Most likely, you’ve added the plugin configuration to the wrong build file. Verify that the plugin is used in the correct build file. Check&nbsp;[Instrument your application via Dynatrace Android Gradle plugin](https://docs.dynatrace.com/docs/shortlink/dynatrace-android-gradle-plugin-first-steps)&nbsp;for the detailed instructions.

## Why do I see the message `The Dynatrace Android Gradle plugin can’t be directly applied to a Java- or Android-related module`?

Your project does not use the&nbsp;[recommended architecture](https://developer.android.com/studio/build#build-files); it uses an uncommon project architecture.

- If your Android project contains only one build file, follow the steps in&nbsp;[Projects with one build file](https://docs.dynatrace.com/docs/shortlink/dynatrace-android-gradle-plugin-uncommon-architectures#one-build-file).
- For other project architectures, check&nbsp;[Change Dynatrace Android Gradle plugin configuration based on the project structure](https://docs.dynatrace.com/docs/shortlink/dynatrace-android-gradle-plugin-uncommon-architectures)&nbsp;or contact a Dynatrace product expert via live chat.

## Why do I see the message `It is not possible to use both Dynatrace plugins (‘com.dynatrace.instrumentation’ and ‘com.dynatrace.instrumentation.module’) for the same module`?

The plugin with the&nbsp;`com.dynatrace.instrumentation`&nbsp;ID automatically configures all modules in your project. Therefore, you don’t need to use the plugin with the&nbsp;`com.dynatrace.instrumentation.module`&nbsp;ID. See&nbsp;[Change Dynatrace Android Gradle plugin configuration based on the project structure](https://docs.dynatrace.com/docs/shortlink/dynatrace-android-gradle-plugin-uncommon-architectures)&nbsp;to understand when you should use the plugin with the&nbsp;`com.dynatrace.instrumentation.module`&nbsp;ID.

If you can’t resolve a build problem with the&nbsp;[Dynatrace Android Gradle plugin](https://docs.dynatrace.com/docs/shortlink/dynatrace-android-gradle-plugin-overview)&nbsp;used for your mobile applications, please contact a Dynatrace product expert via live chat within your Dynatrace environment and&nbsp;[provide&nbsp;the logs](https://docs.dynatrace.com/docs/shortlink/android-logging-oneagent).

For general issues, refer to&nbsp;[Mobile applications: General issues with Dynatrace Android Gradle plugin](https://community.dynatrace.com/topic/234748).
