我已经在我的应用中实施了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[] = {"me@mydomain.com"};
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();
}
}
我真的不知道为什么它不能正常工作..我还在我的Manifest中设置了Internet并设置了我的应用程序名称。
任何帮助都会非常感激! 谢谢!
答案 0 :(得分:2)
正如在ACRA GitHub问题上所讨论的那样,ACRA已作为AAR发布了一段时间。因此,您需要构建并包含AAR,而不是JAR(您必须从AAR挖出来)。
ACRA需要Android服务和资源才能运行。
答案 1 :(得分:-1)
我的问题(我认为)是我正在为API 15及更高版本开发。使用ACRA 4.8.5可能是问题,因为使用ACRA 4.7.0工作正常!