Skip to content

Commit 3e1d6df

Browse files
committed
Catch and log exceptions when enabling tracing.
Due to an android gradle bug calls to forceEnableAppTracing() may fail with NoSuchMethodError at runtime. Instead of crashing, just catch and log this exception.
1 parent 7cf2440 commit 3e1d6df

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

runner/monitor/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
**Bug Fixes**
88

9+
* Catch and log NoSuchMethodError on forceEnableAppTracing calls
10+
911
**New Features**
1012

1113
**Breaking Changes**

runner/monitor/java/androidx/test/platform/tracing/AndroidXTracer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ public AndroidXTracer enableTracing() {
5959
// The AndroidX call can fail if reflection is not allowed.
6060
// We want to log the error yet we should not break any test in this case.
6161
Log.e(TAG, "enableTracing failed", e);
62+
} catch (NoSuchMethodError e) {
63+
// This can occur if an androidx.tracing < 1.1.0 is put on classpath instead.
64+
// See http://issuetracker.google.com/349628366).
65+
// We want to log the error yet we should not break any test in this case.
66+
Log.e(TAG, "enableTracing failed. "
67+
+ "You may need to upgrade your androidx.tracing:tracing version", e);
6268
}
6369
return this;
6470
}

0 commit comments

Comments
 (0)