ConsentSdkCrashGuard
Keeps a known crash inside the User Messaging Platform SDK from killing the host process.
What the SDK does
user-messaging-platform:4.0.0 pings a metrics reporting URL after a failed consent request. When the response is not 200/204 it reads the error body with:
new Scanner(connection.getErrorStream()).useDelimiter("\\A").next();The stream is null-checked, the body is not, so an empty error body makes Scanner.next() throw NoSuchElementException. The ping runs on the SDK's own ThreadPoolExecutor, so no catch in UmpConsentRemoteDataSource, DefaultConsentRepository, or RequestConsentUseCase can ever see it: an uncaught throwable on a plain executor thread reaches the default uncaught-exception handler and takes the process down. 4.0.0 is the newest published version, so there is no upgrade that fixes the read.
What this guard does
It wraps the default uncaught-exception handler and swallows only that exact failure, recording it as a non-fatal instead. The ping is pure telemetry for Google: dropping it has no functional effect on the consent flow, which has already reported its own error to the caller by this point.
The predicate is deliberately narrow, every condition must hold:
the throwable is a NoSuchElementException;
the stack trace contains a
java.util.Scannerframe;the stack trace contains a
com.google.android.gms.internal.consent_sdkframe;the crashing thread is not the main thread.
Anything else is passed straight to the previous handler, unchanged.
The real fix for the underlying failure is upstream (Google), and the fix for the cause is on our side: pointing the consent request at the host app's own AdMob app id (see AdMobAppIdDataSource) and never running two consent round trips at once (see DefaultConsentRepository). This guard covers the remainder and should be removed once a user-messaging-platform release fixes the read, verified by decompiling, not by release notes.