2014-05-22 3 views
0

안녕하세요 에어 브레이크에 충돌 보고서를 보내야합니다.하지만 ACRA는 안드로이드 플랫폼에서이 목적을 위해 훨씬 더 강력한 도구라고 믿습니다. AirbrakeNotifier.notify();을 수행하는 ACRA에 대해 ReposrtSender을 구현하십시오. 아쉽게도 예외로 매개 변수를 사용해야하지만 send() 메서드는 CrashReportData 만 제공합니다. 여기 ACRA 커스텀 센더에서 Exception 또는 Throwable을 얻는 방법

public interface ReportSender { 
    /** 
    * Send crash report data. You don't have to take care of managing Threads, 
    * just implement what is necessary to handle the data. ACRA will use a 
    * specific Thread (not the UI Thread) to run your sender. 
    * 
    * @param errorContent 
    *   Stores key/value pairs for each report field. A report field 
    *   is identified by a {@link ReportField} enum value. 
    * @throws ReportSenderException 
    *    If anything goes fatally wrong during the handling of crash 
    *    data, you can (should) throw a {@link ReportSenderException} 
    *    with a custom message. 
    */ 

    public void send(CrashReportData errorContent) throws ReportSenderException; 
} 

는 에어 브레이크에 보고서를 보내야 보낸 사람의 내 구현 :

public class MyReportSender implements ReportSender { 
    public void send(CrashReportData errorContent) throws ReportSenderException { 
     AirbrakeNotifier.notify(/*Exception is required here*/); 
     // But only key/value pairs are available here in errorContent param. 
    } 
} 
내가 CrashReporData에서 일부 데이터를 새로운 예외를 만들 수 있지만 원래 하나를 얻을 훨씬 더 나은 것으로 나타났습니다

만약에 가능하다면.

프로젝트의 libs와 디렉토리 내부

답변

0

장소 ACRA jar 파일과 CrashReport.java이

@ReportsCrashes(formUri = "http://www.bugsense.com/api/acra?api_key=6f3855c9", formKey="") 
//api_key you will get once you register your application with ACRA. 

public class CrashReport extends Application { 
@Override 
public void onCreate() { 
    super.onCreate(); 

    // The following line Application register with ACRA 
    ACRA.init(this); 
} 
} 

여기이

android:name="com.example.mydoc.CrashReport" 

같은 menifest.xml 파일 내부 응용 프로그램 태그 안에 귀하의 충돌 보고서 클래스를 설정 파일 생성 com.example.mydoc은 충돌 보고서가있는 응용 프로그램 패키지입니다.

+0

예외는 어디입니까? –

+0

이것은 예외 정보를 수집하기 위해 프로젝트를 ACRA에 등록 할 수있는 방법입니다. 모든 클래스에서 예외를 원한다면 정수에서 null 값을 파싱 할 수 있습니다. ACRA에서 예외가 발생합니다. –

+0

불행히도 어떤 식 으로든 도움이되지 않습니다. 프로젝트의 등록 ACRA가 아니라 맞춤 발신자의 Excetion에 대한 질문입니다. 시도해 주셔서 감사합니다. –

0

비록이 질문이 오래되었지만 나는 Google을 통해 그것을 발견하고 다른 사람들도 그렇게 할 수 있습니다.


ReportSender 내부 Exception를 얻을 수 없다. 스택 추적을 얻을 수는 있지만 객체 자체는 아닙니다. 왜냐하면 객체 자체는 보낸 사람과 다른 프로세스에 있으며 현재는 가비지 수집을하고 있기 때문입니다.

개체가 필요한 경우 대신 ReportPrimer을 사용할 수 있습니다. 보고서가 작성되기 전에 호출되므로 Exception 개체 (예 : 충돌 한 Thread과 같은 다른 데이터 중에서)를 포함하는 ReportBuilder에 액세스 할 수 있습니다.