我正在尝试将ACRA集成到我的Android应用程序中。我想通过POST方式发送包含JSON的崩溃报告。为此,我已经配置了ACRA并创建了以下类:
import android.app.Application;
import org.acra.ACRA;
import org.acra.ReportField;
import org.acra.ReportingInteractionMode;
import org.acra.annotation.*;
import org.acra.sender.HttpSender;
@ReportsCrashes(
formUri = "https://mySite/myFolder/report.php",
reportType = HttpSender.Type.JSON,
httpMethod = HttpSender.Method.POST,
formUriBasicAuthLogin = "username",
formUriBasicAuthPassword = "password",
formKey = "", // This is required for backward compatibility but not used
customReportContent = {
ReportField.APP_VERSION_CODE,
ReportField.APP_VERSION_NAME,
ReportField.ANDROID_VERSION,
ReportField.PACKAGE_NAME,
ReportField.REPORT_ID,
ReportField.BUILD,
ReportField.STACK_TRACE
},
mode = ReportingInteractionMode.SILENT)
public class Crazy extends Application {
public void onCreate() {
super.onCreate();
ACRA.init(this);
}
}
我目前正在自愿地使我的应用程序崩溃,以测试ACRA。当应用程序崩溃时,logcat会显示以下错误:
09-18 14:25:53.943 20309-20324/myPackage I/ACRA﹕ Sending file 1411042794000-approved.stacktrace
09-18 14:25:53.958 20309-20309/myPackage D/OpenGLRenderer﹕ Enabling debug mode 0
09-18 14:25:53.968 20309-20324/myPackage D/ACRA﹕ Connect to https://mySite/myFolder/report.php
09-18 14:25:53.983 20309-20312/myPackage D/dalvikvm﹕ GC_CONCURRENT freed 414K, 15% free 9757K/11399K, paused 13ms+13ms, total 58ms
09-18 14:25:54.008 20309-20324/myPackage D/ACRA﹕ Sending request to https://mySite/myFolder/report.php
09-18 14:25:54.153 20309-20324/myPackage E/ACRA﹕ Failed to send crash report for 1411042794000-approved.stacktrace
org.acra.sender.ReportSenderException: Error while sending JSON report via Http POST
at org.acra.sender.HttpSender.send(HttpSender.java:228)
at org.acra.SendWorker.sendCrashReport(SendWorker.java:179)
at org.acra.SendWorker.checkAndSendReports(SendWorker.java:141)
at org.acra.SendWorker.run(SendWorker.java:77)
Caused by: javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
at org.apache.harmony.xnet.provider.jsse.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:137)
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:93)
at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:381)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:165)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
at org.acra.util.HttpRequest.send(HttpRequest.java:152)
at org.acra.sender.HttpSender.send(HttpSender.java:225)
at org.acra.SendWorker.sendCrashReport(SendWorker.java:179)
at org.acra.SendWorker.checkAndSendReports(SendWorker.java:141)
at org.acra.SendWorker.run(SendWorker.java:77)
09-18 14:25:54.153 20309-20324/myPackage D/ACRA﹕ #checkAndSendReports - finish
我该如何解决这个问题?
谢谢!