Skip to content

Incorrect usage of Android adservices service caused an abnormal crash. #1357

@SunOnTheCloud66

Description

@SunOnTheCloud66

Checklist before submitting a bug report

Java version

17

Android version

Android 11

Android SDK version

18.0.0

Installation platform & version

Gradle

Package

Core & AppEvents

Goals

fix crash

Expected results

Using the official standard API to check if the feature is supported.
androidorAndroidx-Privacy Sandbox

Actual results

Incorrect use of the MeasurementManager API on Android 11 resulted in a crash.

Image

private fun canRegisterTrigger(): Boolean {
if (!enabled) {
return false
}
try {
Class.forName("android.adservices.measurement.MeasurementManager")
return true
} catch (e: Exception) {
Log.i(TAG, "FAILURE_NO_MEASUREMENT_MANAGER_CLASS")
gpsDebugLogger.log(
Constants.GPS_ARA_FAILED,
Bundle().apply { putString(Constants.GPS_ARA_FAILED_REASON, e.toString()) })
return false
} catch (e: Error) {
Log.i(TAG, "FAILURE_NO_MEASUREMENT_MANAGER_CLASS")
gpsDebugLogger.log(
Constants.GPS_ARA_FAILED,
Bundle().apply { putString(Constants.GPS_ARA_FAILED_REASON, e.toString()) })
return false
}
}

Find the crash by the name of the crashing thread and determine that the crash was triggered by the Facebook SDK

measurementManager.registerTrigger(
attributionTriggerUri, FacebookSdk.getExecutor(), outcomeReceiver
)

gradle-8.11.1
Android gradle plugin 8.10.0
minSdkVersion 23

android {
    compileOptions {
        coreLibraryDesugaringEnabled true
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
}
dependencies {
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions