web/docs/Custom-Extensions.mdx
import {GradleCode, AndroidCode} from "@theme/Code";
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:
<AndroidCode>class MyAdmin : ReportingAdministrator {
init {
Log.d("MyAdmin", "MyAdmin was loaded")
}
}
public MyAdmin implements ReportingAdministrator {
public MyAdmin() {
Log.d("MyAdmin", "MyAdmin was loaded");
}
}
| Supported Extensions | Use Case |
|---|---|
Collector | Collect additional custom data not covered by acra |
ApplicationStartupCollector | Collector which is also called at startup |
ReportInteraction | Usually not needed, as the provided options (dialog, notification, toast) cover all reasonable choices |
ReportingAdministrator | Control when reports are generated and when the application should be stopped |
ReportSenderFactory | Register custom report senders |
ConfigurationBuilderFactory | Register custom configurations |
SenderSchedulerFactory | Register custom sender scheduler, e.g. to prevent report sending based on custom conditions |
StartupProcessor | Do something ACRA related on app start |
Choose one of the following alternatives:
Add the following dependencies: <GradleCode>
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")
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:
<AndroidCode>@AutoService(<ExtensionInterface>::class)
@AutoService(<ExtensionInterface>.class)
To manually register your extension, create a text file in src/main/resources/META-INF/services/ named after the fully qualified interface name (e.g., org.acra.sender.ReportSenderFactory) containing the fully qualified name of your implementation class:
com.example.myapp.MySenderFactory
Your implementation must be public and have a public zero-argument constructor.
See ServiceLoader for more details.