# The Dynatrace Android Gradle Plugin can only be applied to Android application projects

**URL:** <https://community.dynatrace.com/t/the-dynatrace-android-gradle-plugin-can-only-be-applied-to-android-application-projects/35729>\
**Category:** Real User Monitoring\
**Tags:** android, mobile-monitoring\
**Created:** [July 4, 2022, 4:32pm UTC](https://community.dynatrace.com/t/the-dynatrace-android-gradle-plugin-can-only-be-applied-to-android-application-projects/35729 "2022-07-04T16:32:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![fnaku](https://avatars.discourse-cdn.com/v4/letter/f/46a35a/32.png) [@fnaku](https://community.dynatrace.com/u/fnaku)\
**Post date:** [July 4, 2022, 4:32pm UTC](https://community.dynatrace.com/t/the-dynatrace-android-gradle-plugin-can-only-be-applied-to-android-application-projects/35729/1 "2022-07-04T16:32:01Z")

</div>

In our android project we are implementing dynatrace. I followed steps from this link: [Instrumentation via plugin](https://www.dynatrace.com/support/help/how-to-use-dynatrace/real-user-monitoring/setup-and-configuration/mobile-apps/instrument-android-app/instrumentation-via-plugin/instrumentation-via-plugin#tabgroup--dynatrace-configuration--kotlin) and my root build.gradle.kts looks like this:

```auto
buildscript {

    repositories {
        google()
        jcenter()
        mavenCentral()

    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.1.3")
        classpath("com.dynatrace.tools.android:gradle-plugin:8.+")
        ...
    }
}
apply(plugin = "com.dynatrace.instrumentation")
configure<com.dynatrace.tools.android.dsl.DynatraceExtension> {
    configurations {
        create("sampleConfig") {
            userOptIn(true)
            debug {
                agentLogging(true)
            }
            autoStart {
                applicationId("...")
                beaconUrl("...")
            }
        }
    }
}

```

Project builds fine but now I noticed when I try to run gradle task for example **compileDebugUnitTestKotlin** from module other than my app module I get error _ **The Dynatrace Android Gradle Plugin can only be applied to Android application projects.** _

All I could find on this is this entry in FAQ: [FAQ entry](https://www.dynatrace.com/support/help/how-to-use-dynatrace/real-user-monitoring/setup-and-configuration/mobile-apps/instrument-android-app/troubleshooting/faqs#expand--why-do-i-see-the-message-the-dynatrace-android-gradle-plugin-can-only-be-applied-to-android-projects--15) but it doesn’t help me at all because my project is in fact Android project. Why is this gradle task failing with this error and how can I fix that?

---

<div class="post-metadata">

**Author:** ![Thomas\_Wirth1](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/thomas_wirth1/32/1776_2.png) [@Thomas\_Wirth1](https://community.dynatrace.com/u/Thomas_Wirth1)\
**Post date:** [July 5, 2022, 8:35am UTC](https://community.dynatrace.com/t/the-dynatrace-android-gradle-plugin-can-only-be-applied-to-android-application-projects/35729/2 "2022-07-05T08:35:10Z")

</div>

Hey fnaku,

this error message should only be shown, when there is no “app” subproject/module in your Gradle project. The Dynatrace Android Gradle plugin checks if the “com.android.application” plugin is applied.

What is the “module type” of the other module (for example: Android library, Dynamic feature module, …)?

What Gradle version are you using?

I would recommend to create a support ticket. Then you can upload the build files&nbsp;(and upload the Gradle debug logs). With this information we can troubleshoot your problem.

Dynatrace also provides a second plugin, where you can directly instrument the Android app module. But then the plugin configuration is not shared between different modules. For more information see

> **[Change Dynatrace Android Gradle plugin configuration based on the project...](https://docs.dynatrace.com/docs/observe/digital-experience/rum-classic/mobile-applications/instrument-android-app/instrumentation-via-plugin/configure-multi-module-projects)**
>
> Use the Dynatrace Android Gradle plugin for less common project architectures.

---

<div class="post-metadata">

**Author:** ![fnaku](https://avatars.discourse-cdn.com/v4/letter/f/46a35a/32.png) [@fnaku](https://community.dynatrace.com/u/fnaku)\
**Post date:** [July 6, 2022, 10:58am UTC](https://community.dynatrace.com/t/the-dynatrace-android-gradle-plugin-can-only-be-applied-to-android-application-projects/35729/3 "2022-07-06T10:58:09Z")

</div>

My other modules are Android library

```auto
plugins {
    id("com.android.library")
    ...
}

```

And I am using gradle 7.2

When I changed **id(“com.android.library”)** to **id(“com.android.application”)** in my module’s **build.gradle.kts** then gradle task **compileDebugUnitTestKotlin** completes successfuly. But I don’t want to change that.

---

<div class="post-metadata">

**Author:** ![techean](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/techean/32/227_2.png) [@techean](https://community.dynatrace.com/u/techean)\
**Post date:** [July 6, 2022, 11:43am UTC](https://community.dynatrace.com/t/the-dynatrace-android-gradle-plugin-can-only-be-applied-to-android-application-projects/35729/4 "2022-07-06T11:43:33Z")

</div>

This will need an RFE request to mod the grade plugin as per your requirement. Please raise a support ticket for same !!!😊

---

<div class="post-metadata">

**Author:** ![Thomas\_Wirth1](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/thomas_wirth1/32/1776_2.png) [@Thomas\_Wirth1](https://community.dynatrace.com/u/Thomas_Wirth1)\
**Post date:** [July 6, 2022, 1:29pm UTC](https://community.dynatrace.com/t/the-dynatrace-android-gradle-plugin-can-only-be-applied-to-android-application-projects/35729/5 "2022-07-06T13:29:25Z")

</div>

In my project the task “:lib:compileDebugUnitTestKotlin” works and there is no error message from the Dynatrace Android Gradle plugin. Having library modules in your Android project is supported.

As written in my last comment, we would need more information from your Android project to understand the project setup and determine why the plugin believes you do not have an application module.

---

<div class="post-metadata">

**Author:** ![kasdev](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@kasdev](https://community.dynatrace.com/u/kasdev)\
**Post date:** [February 13, 2024, 3:18pm UTC](https://community.dynatrace.com/t/the-dynatrace-android-gradle-plugin-can-only-be-applied-to-android-application-projects/35729/6 "2024-02-13T15:18:10Z")

</div>

hello.

i really wonder that if you’ve solved the issue?

i’ve been experiencing the same problem for 2 days and i’ve searched everthing but i got no progress.

---

<div class="post-metadata">

**Author:** ![Thomas\_Wirth1](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/thomas_wirth1/32/1776_2.png) [@Thomas\_Wirth1](https://community.dynatrace.com/u/Thomas_Wirth1)\
**Post date:** [February 13, 2024, 4:15pm UTC](https://community.dynatrace.com/t/the-dynatrace-android-gradle-plugin-can-only-be-applied-to-android-application-projects/35729/7 "2024-02-13T16:15:57Z")

</div>

Hey kasdev,  
The Dynatrace Android Gradle plugin can only be used in projects that use the Android Gradle plugin to build an Android app. It is not possible to instrument an (independent) library project, because this use case is not supported by Dynatrace.

Can you share the exact error message? So we know the exact problem that the Dynatrace plugin detected.  
You can also create a support ticket and the support team will help you troubleshoot the error message.
