Skip to main content

Custom Extensions

Implementing an extension

Create a class extending one of the supported interfaces.

It has to be public and have a zero-argument public constructor (as a result, it cannot be an inner class).

Example:

MyAdmin : ReportingAdministrator {
init {
Log.d("MyAdmin", "MyAdmin was loaded")
}
}
Supported ExtensionsUse Case
CollectorCollect additional custom data not covered by acra
ApplicationStartupCollectorCollector which is also called at startup
ReportInteractionUsually not needed, as the provided options (dialog, notification, toast) cover all reasonable choices
ReportingAdministratorControl when reports are generated and when the application should be stopped
ReportSenderFactoryRegister custom report senders
ConfigurationBuilderFactoryRegister custom configurations
SenderSchedulerFactoryRegister custom sender scheduler, e.g. to prevent report sending based on custom conditions
StartupProcessorDo something ACRA related on app start

Registering an extension

Choose one of the following alternatives:

By annotation

Add the following dependencies:

build.gradle.kts
compileOnly("com.google.auto.service:auto-service-annotations:1.1.1")
//either for java sources:
annotationProcessor("com.google.auto.service:auto-service:1.1.1")
//or for kotlin sources (requires kapt gradle plugin):
kapt("com.google.auto.service:auto-service:1.1.1")
//or for ksp(requires ksp gradle plugin):
ksp("dev.zacsweers.autoservice:auto-service-ksp:1.1.0")
ksp("com.google.auto.service:auto-service:1.1.1")

Then annotate your extension with the following:

@AutoService(<ExtensionInterface>::class)

By file

See ServiceLoader for manual service registration