本文介绍了使用时,ACRA崩溃的空文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用下面的code生成一个崩溃的文件,该文件是在parse.com创造的,但它是空的。
任何想法,为什么?
的另一个问题是ACRA.DEFAULT_REPORT_FIELDS;有一个错误,默认的报告领域,是不可用的。
公共类LocalSender实现ReportSender {
私人最终地图< ReportField,字符串> mMapping =新的HashMap< ReportField,字符串>();
私人的FileOutputStream crashReport = NULL;
私人上下文CTX;
公共LocalSender(上下文CT){
CTX =克拉;
}
公共无效发送(CrashReportData报告)抛出ReportSenderException {
最终地图<字符串,字符串> finalReport =重映射(报告);
ByteArrayOutputStream BUF =新ByteArrayOutputStream();
Log.i(hcsh,报告发送);
尝试{
设置设置= finalReport.entrySet();
迭代器I = set.iterator();
字符串tmp目录;
而(i.hasNext()){
Map.Entry的<字符串,字符串>我=(Map.Entry的)i.next();
TMP =[+ me.getKey()+=+ me.getValue();
buf.write(tmp.getBytes());
}
ParseFile MYFILE =新ParseFile(crash.txt,buf.toByteArray());
myFile.save();
的parseObject在线招聘=新的parseObject(APPCRASH);
jobApplication.put(MyCrash,应用程序名称);
jobApplication.put(applicantResumeFile,MYFILE);
尝试{
jobApplication.save();
}赶上(ParseException的E){
// TODO自动生成catch块
e.printStackTrace();
}
}赶上(FileNotFoundException异常五){
Log.e(TAG,IO ERROR,E);
}
赶上(IOException异常五){
Log.e(TAG,IO ERROR,E);
}赶上(ParseException的E){
// TODO自动生成catch块
e.printStackTrace();
}
}
私人地图<字符串,字符串>重映射(地图< ReportField,字符串>报告){
ReportField []栏= ACRA.getConfig()customReportContent()。
如果(fields.length == 0){
田= ACRA.DEFAULT_REPORT_FIELDS;
}
最终地图<字符串,字符串> finalReport =新的HashMap<字符串,字符串>(
report.size());
对于(ReportField场:场){
如果(mMapping == NULL || mMapping.get(场)== NULL){
finalReport.put(field.toString(),report.get(场));
}其他{
finalReport.put(mMapping.get(场),report.get(场));
}
}
返回finalReport;
} }
解决方案
有没有这样的常数 ACRA.DEFAULT_REPORT_FIELDS
。您正在寻找 ACRAConstants.DEFAULT_REPORT_FIELDS
i am using the code below to generate a crash file, the file is created at parse.com but it is empty.any idea why?
Another problem is that "ACRA.DEFAULT_REPORT_FIELDS;" has an error, default report fields is not available.
public class LocalSender implements ReportSender {
private final Map<ReportField, String> mMapping = new HashMap<ReportField, String>() ;
private FileOutputStream crashReport = null;
private Context ctx;
public LocalSender(Context ct) {
ctx = ct;
}
public void send(CrashReportData report) throws ReportSenderException {
final Map<String, String> finalReport = remap(report);
ByteArrayOutputStream buf = new ByteArrayOutputStream();
Log.i("hcsh","Report send");
try {
Set set = finalReport.entrySet();
Iterator i = set.iterator();
String tmp;
while (i.hasNext()) {
Map.Entry<String,String> me = (Map.Entry) i.next();
tmp = "[" + me.getKey() + "]=" + me.getValue();
buf.write(tmp.getBytes());
}
ParseFile myFile = new ParseFile("crash.txt", buf.toByteArray());
myFile.save();
ParseObject jobApplication = new ParseObject("AppCrash");
jobApplication.put("MyCrash", "app name");
jobApplication.put("applicantResumeFile", myFile);
try {
jobApplication.save();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}catch (FileNotFoundException e) {
Log.e("TAG", "IO ERROR",e);
}
catch (IOException e) {
Log.e("TAG", "IO ERROR",e);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private Map<String, String> remap(Map<ReportField, String> report) {
ReportField[] fields = ACRA.getConfig().customReportContent();
if (fields.length == 0) {
fields = ACRA.DEFAULT_REPORT_FIELDS;
}
final Map<String, String> finalReport = new HashMap<String, String>(
report.size());
for (ReportField field : fields) {
if (mMapping == null || mMapping.get(field) == null) {
finalReport.put(field.toString(), report.get(field));
} else {
finalReport.put(mMapping.get(field), report.get(field));
}
}
return finalReport;
}
}
解决方案
There is no such constant as ACRA.DEFAULT_REPORT_FIELDS
. You are looking for ACRAConstants.DEFAULT_REPORT_FIELDS
这篇关于使用时,ACRA崩溃的空文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!