04 Jul 2022 05:32 PM
In our android project we are implementing dynatrace. I followed steps from this link: Instrumentation via plugin and my root build.gradle.kts looks like this:
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 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?
Solved! Go to Solution.
05 Jul 2022 09:35 AM
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 (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
06 Jul 2022 11:58 AM - edited 06 Jul 2022 12:00 PM
My other modules are Android library
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.
06 Jul 2022 12:43 PM
This will need an RFE request to mod the grade plugin as per your requirement. Please raise a support ticket for same !!!😊
06 Jul 2022 02:29 PM
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.
13 Feb 2024 03:18 PM
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.
13 Feb 2024 04:15 PM
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.