我使用ACRA 5.8.4,我想将其更新到5.9.6,但@annotations已被弃用,我不得不将其更改为PluginConfigurations,但文档尚未完成,我不知道如何完成。这是我当前的应用程序类:
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 = "myemail@mydomain.com",
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);
}
}
我想将其更新为插件配置:
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);
}
}
您可以使用
.withPluginConfigurations(
new DialogConfigurationBuilder()
.withCommentPrompt(getString(R.string.crash_dialog_comment_prompt))
.withText(getString(R.string.crash_dialog_text))
.build(),
new MailSenderConfigurationBuilder()
.withMailTo("crash@report.xx")
.withReportAsFile(true)
.withReportFileName("Crash.txt")
.withBody("getString(R.string.mail_body)")
.build()
)
配置生成器的示例可以在以下网站上找到:https://www.acra.ch/docs/Senders