Reputation: 933
I've implemented ACRA 4.8.5 in my app and it is initialized and enabled and all but when I face a bug, it doesn't create a report... The only two related ACRA logs I have are:
I/ACRA: ACRA is enabled for com.mydomain.myapp, initializing...
and
E/ACRA: ACRA caught a RuntimeException for com.mydomain.myapp
I have this in my application class
@ReportsCrashes(reportSenderFactoryClasses = {ACRASenderFactory.class})
and
@Override
public void onCreate() {
super.onCreate();
ACRA.init(this);
}
Here is my ACRASenderFactory class
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();
}
}
and here is my ACRAReportSender class
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();
}
}
I really don't know why it's not working.. I've also allowed Internet in my Manifest and set my app name.
Any help would be really appreciated! Thanks!
Upvotes: 1
Views: 612
Reputation: 20196
As discussed on the ACRA GitHub issue, ACRA has shipped as an AAR for some time now. So you need to build and include the AAR, not the JAR (which you must have dug out of the AAR).
ACRA requires Android services and resources in order to run.
Upvotes: 2
Reputation: 933
My problem (I think) was that I am developping for API 15 and up. Using ACRA 4.8.5 might have been the problem since using ACRA 4.7.0 works just fine!
Upvotes: -1