我已经在我的应用程序中实现了ACRA 4.8.5,并对其进行了初始化和启用,但是当我遇到错误时,它都不会创建报告...我仅有的两个相关ACRA日志是:
I/ACRA: ACRA is enabled for com.mydomain.myapp, initializing...
和
E/ACRA: ACRA caught a RuntimeException for com.mydomain.myapp
我的应用程序班里有这个
@ReportsCrashes(reportSenderFactoryClasses = {ACRASenderFactory.class})
和
@Override
public void onCreate() {
super.onCreate();
ACRA.init(this);
}
这是我的ACRASenderFactory类
public class ACRASenderFactory implements ReportSenderFactory {
public ACRASenderFactory(){
Log.e("ACRA", "Create Sender Factory");
}
@NonNull
@Override
public ReportSender create(Context context, ACRAConfiguration acraConfiguration) {
Log.e("ACRA", "Return Report Sender");
return new ACRAReportSender();
}
}
这是我的ACRAReportSender类
public class ACRAReportSender implements ReportSender {
public ACRAReportSender(){
Log.e("ACRA", "Report Sender created");
}
@Override
public void send(Context context, CrashReportData crashReportData) throws ReportSenderException {
Log.e("ACRA", "Trying to send crash report");
String reportBody = createCrashReport(crashReportData);
// Send body using email
Intent emailIntent = new Intent(Intent.ACTION_SEND);
// Set type to "email"
emailIntent.setType("vnd.android.cursor.dir/email");
String to[] = {"[email protected]"};
emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
// Text
emailIntent.putExtra(Intent.EXTRA_TEXT, reportBody);
// Set the subject
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "ACRA Crash Report");
context.startActivity(Intent.createChooser(emailIntent, "Send crash to developpers by email ..."));
}
private String createCrashReport(CrashReportData crashReportData){
StringBuilder body = new StringBuilder();
body.append("Device : " + crashReportData.getProperty(ReportField.BRAND) + " - " + crashReportData.getProperty(ReportField.PHONE_MODEL))
.append("\n")
.append("Android Version : " + crashReportData.getProperty(ReportField.ANDROID_VERSION))
.append("\n")
.append("App Version : " + crashReportData.getProperty(ReportField.APP_VERSION_CODE))
.append("\n")
.append("STACK TRACE : \n" + crashReportData.getProperty(ReportField.STACK_TRACE));
return body.toString();
}
}
我真的不知道为什么它不起作用。我还允许在清单中设置Internet并设置我的应用程序名称。
任何帮助将非常感激!
谢谢!
最佳答案
正如关于ACRA GitHub问题的讨论,ACRA作为AAR交付已经有一段时间了。因此,您需要构建并包含AAR,而不是JAR(必须从AAR中挖出)。
ACRA需要Android服务和资源才能运行。
关于android - ACRA未创建报告,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36627462/