我已经在我的应用程序中实现了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();
}
}我真的不知道为什么它不工作..我还允许在我的清单中使用互联网,并设置我的应用程序名称。
任何帮助都将不胜感激!谢谢!
发布于 2016-04-16 06:45:56
正如在ACRA GitHub问题上所讨论的,ACRA已经作为AAR发布了一段时间了。因此,您需要构建并包含AAR,而不是JAR (必须从AAR中挖掘出来)。
ACRA需要Android服务和资源才能运行。
发布于 2016-04-15 02:56:51
我的问题(我认为)是我正在为API 15和更高版本进行开发。使用ACRA 4.8.5可能是个问题,因为使用ACRA 4.7.0工作得很好!
https://stackoverflow.com/questions/36627462
复制相似问题