# Exclude a package from dynatrace instrumentation React native

**URL:** <https://community.dynatrace.com/t/exclude-a-package-from-dynatrace-instrumentation-react-native/49789>\
**Category:** Real User Monitoring\
**Tags:** react, mobile-monitoring\
**Created:** [January 17, 2025, 11:58am UTC](https://community.dynatrace.com/t/exclude-a-package-from-dynatrace-instrumentation-react-native/49789 "2025-01-17T11:58:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ancy\_m](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@ancy\_m](https://community.dynatrace.com/u/ancy_m)\
**Post date:** [January 17, 2025, 11:58am UTC](https://community.dynatrace.com/t/exclude-a-package-from-dynatrace-instrumentation-react-native/49789/1 "2025-01-17T11:58:46Z")

</div>

We have integrated a package in our app and android build is failing with the error and wanted to exclude that package from instrumentation in react native app. need help to fix it

---

<div class="post-metadata">

**Author:** ![matthias\_hochri](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/matthias_hochri/32/15052_2.png) [@matthias\_hochri](https://community.dynatrace.com/u/matthias_hochri)\
**Post date:** [January 20, 2025, 7:12am UTC](https://community.dynatrace.com/t/exclude-a-package-from-dynatrace-instrumentation-react-native/49789/2 "2025-01-20T07:12:54Z")

</div>

Is the error happening in the Metro Bundler or during the build itself? Can we see more information about the error?

Feature which is excluding classes from instrumentation:&nbsp;[Configure Dynatrace Android Gradle plugin for instrumentation processes in RUM Classic — Dynatrace Docs](https://docs.dynatrace.com/docs/observe/digital-experience/mobile-applications/instrument-android-app/instrumentation-via-plugin/configure-plugin-for-instrumentation#exclude-classes-and-methods)

You need to copy this configuration into the Android part of dynatrace.config.js.

---

<div class="post-metadata">

**Author:** ![ancy\_m](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@ancy\_m](https://community.dynatrace.com/u/ancy_m)\
**Post date:** [January 21, 2025, 11:26am UTC](https://community.dynatrace.com/t/exclude-a-package-from-dynatrace-instrumentation-react-native/49789/3 "2025-01-21T11:26:10Z")

</div>

[@matthias\_hochri](https://community.dynatrace.com/user/2925)&nbsp; its happening during the build and we tried the above mentioned steps but still its throwing error.

 ![Screenshot 2025-01-02 at 5.53.40 PM 1.png](https://global.discourse-cdn.com/dynatrace/original/2X/2/2f685b92e399ab8f69cd7805bb4bdf8d56f238a8.png)

---

<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:** [January 21, 2025, 5:00pm UTC](https://community.dynatrace.com/t/exclude-a-package-from-dynatrace-instrumentation-react-native/49789/4 "2025-01-21T17:00:47Z")

</div>

Hey ancy\_m,  
your Android build failed because an Android Gradle task could not receive all class files. The “Error occurred while instrumenting” error message is from the Android Gradle plugin.  
It could be related to Dynatrace, because the Dynatrace ReactNative plugin uses the affected feature from the Android Gradle plugin. But without additional information we can’t determine the root cause or verify if it is related to our plugin.  
My recommendation would be to open a support ticket. There you can upload the whole error message and the support team will assist you in analyzing the problem. As a next step, we would also need the Gradle debug logs to check if Dynatrace modified the affected class.

---

<div class="post-metadata">

**Author:** ![ancy\_m](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@ancy\_m](https://community.dynatrace.com/u/ancy_m)\
**Post date:** [January 22, 2025, 3:53pm UTC](https://community.dynatrace.com/t/exclude-a-package-from-dynatrace-instrumentation-react-native/49789/5 "2025-01-22T15:53:34Z")

</div>

[@Thomas\_Wirth1](https://community.dynatrace.com/user/35396)

\> Task :app:dexBuilderRelease FAILED  
Unable to find common super type for com/clarisite/mobile/m/l and java/lang/Object.  
Unable to find common super type for com/clarisite/mobile/m/l and com/clarisite/mobile/m/n.  
Unable to find common super type for java/lang/String and androidx/fragment/app/FragmentManager.  
Unable to find common super type for java/lang/Object and androidx/fragment/app/FragmentManager.  
Unable to find common super type for okhttp3/HttpUrl and okhttp3/Request.  
Unable to find common super type for okhttp3/HttpUrl and java/lang/Object.  
Unable to find common super type for okhttp3/Response and java/lang/Object.  
Unable to find common super type for okhttp3/Request and com/clarisite/mobile/g/m.  
Unable to find common super type for okhttp3/Request and java/lang/Object.  
Unable to find common super type for com/clarisite/mobile/g/q and okhttp3/Response.  
Unable to find common super type for okhttp3/ResponseBody and okhttp3/Response.  
Unable to find common super type for okhttp3/ResponseBody and java/lang/Object.  
Unable to find common super type for okio/BufferedSource and java/lang/Object.  
Unable to find common super type for okhttp3/RequestBody and com/clarisite/mobile/g/m.  
Unable to find common super type for okhttp3/RequestBody and java/lang/Object.  
Unable to find common super type for okio/Buffer and java/lang/Object.  
Unable to find common super type for okio/Buffer and okhttp3/RequestBody.

FAILURE: Build failed with an exception.

\* What went wrong:  
Execution failed for task ‘:app:dexBuilderRelease’.  
\> Could not resolve all files for configuration ‘:app:releaseRuntimeClasspath’.  
\> Failed to transform glassbox.jar to match attributes {artifactType=android-asm-instrumented-jars, asm-transformed-variant=release, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.  
\> Execution failed for AsmClassesTransform: /Users/vmajoka/.gradle/caches/transforms-3/b1dc10c8926c81cd0f2ea8014eaefb38/transformed/jetified-glassbox.jar.  
\> Error occurred while instrumenting class com.clarisite.mobile.g.s$a

\* Try:  
\> Run with --stacktrace option to get the stack trace.  
\> Run with --info or --debug option to get more log output.  
\> Run with --scan to get full insights.

\* Get more help at

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use ‘--warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

Execution optimizations have been disabled for 1 invalid unit(s) of work during this build to ensure correctness.  
Please consult deprecation warnings for more details.

BUILD FAILED in 3m 53s  
832 actionable tasks: 785 executed, 47 up-to-date  
/Users/vmajoka/Documents/NewWork/Mobile-OptumRx/packages/common\_mock/shared/common.js:78  
&nbsp; throw new Error(message);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^

Error: Failed to build Android app  
&nbsp;&nbsp;&nbsp; at Object.endProcess (/Users/vmajoka/Documents/NewWork/Mobile-OptumRx/packages/common\_mock/shared/common.js:78:9)  
&nbsp;&nbsp;&nbsp; at Object.build (/Users/vmajoka/Documents/NewWork/Mobile-OptumRx/packages/app/util/buildAndroid.js:31:12)  
&nbsp;&nbsp;&nbsp; at process.processTicksAndRejections (node:internal/process/task\_queues:95:5)  
&nbsp;&nbsp;&nbsp; at async startAsyncBuild (/Users/vmajoka/Documents/NewWork/Mobile-OptumRx/packages/app/util/build.js:208:7)

Node.js v18.14.0  
error Command failed with exit code 1.&nbsp;@

---

<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:** [January 22, 2025, 5:09pm UTC](https://community.dynatrace.com/t/exclude-a-package-from-dynatrace-instrumentation-react-native/49789/6 "2025-01-22T17:09:52Z")

</div>

Gradle does not print the whole stacktrace. You have to run the command with the --stacktrace option (or -s). To print the debug logs, you have to add the -d option. When you run the following command, the Gradle debug logs will be stored in the file debugLogs.txt

```java
./gradlew assembleRelease -d -s > debugLogs.txt 2>&1

```

As mentioned in my previous ticket, the official workflow is to create a support ticket and attach this information.
