Migrating ACRA from annotations to pluginconfigurations

188 views Asked by At

I use ACRA 5.8.4 and I want to update it to 5.9.6 but @annotations are deprecated and I have to change it to PluginConfigurations, but documentation isn't finished and I don't know how to do it. This is my current Application class:

package com.mycompany.myapp;

import android.app.Application;
import android.content.Context;
import androidx.multidex.MultiDex;

import org.acra.ACRA;
import org.acra.annotation.AcraCore;
import org.acra.annotation.AcraDialog;
import org.acra.annotation.AcraMailSender;

@AcraCore(buildConfigClass = BuildConfig.class)
@AcraMailSender(mailTo = "[email protected]",
                resSubject = R.string.mailsubject)
@AcraDialog(resTitle = R.string.acratitle,
            resText = R.string.acratext,
            resPositiveButtonText = R.string.acrasend,
            resNegativeButtonText = R.string.acracancel,
            resCommentPrompt = R.string.acracomprompt )
public class MyAwsomeApplication extends Application {

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);

        // The following line triggers the initialization of ACRA
        ACRA.init(this);
    }
}

And I want to update it to pluginconfigurations:

public class MyAwsomeApplication extends Application {

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);

        // The following line triggers the initialization of ACRA
        CoreConfigurationBuilder builder;
        builder = new CoreConfigurationBuilder()
                    .withBuildConfigClass(BuildConfig.class)
                    .withReportFormat(StringFormat.JSON)
                    .withPluginConfigurations(
                    <-- I think, here I should add new clases for dialog and mail sender -->        
                    );

        ACRA.init(this, builder);
    }
}
1

There are 1 answers

0
Raphael Mack On

You can use

      .withPluginConfigurations(
           new DialogConfigurationBuilder()
               .withCommentPrompt(getString(R.string.crash_dialog_comment_prompt))
               .withText(getString(R.string.crash_dialog_text))
               .build(),
           new MailSenderConfigurationBuilder()
               .withMailTo("[email protected]")
               .withReportAsFile(true)
               .withReportFileName("Crash.txt")
               .withBody("getString(R.string.mail_body)")
               .build()
       )

examples for configuration builders can be found on: https://www.acra.ch/docs/Senders