Android - 如何在Android中使用Arca作为bug记者?

时间:2015-09-28 08:50:48

标签: java php android qt bug-reporting

我正在尝试在我的Qt-Android项目中使用 ARCA 作为错误记者。我阅读了this教程,并将.JAR文件添加到我的项目中,在我的项目中创建了新类( ReportApp.java )。

ReportApp.java:

package org.qtproject.example.myApplication;
import org.acra.*;
import org.acra.annotation.*;
import android.app.Application;

@ReportsCrashes(
    formUri = "http://********/report/reportpath.php",
    formUriBasicAuthLogin = "root",
    formUriBasicAuthPassword = "***************",
    mode = ReportingInteractionMode.TOAST,
    forceCloseDialogAfterToast = false, // optional, default false
    resToastText = R.string.crash_toast_text)
public class ReportApp extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        ACRA.init(this);
    }
}

在AndroidManifest.xml中编辑此行:

而不是使用

<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="@string/app_name" android:icon="@drawable/icon">

我用:

<application android:hardwareAccelerated="true" android:name="org.qtproject.example.myApplication.ReportApp" android:label="@string/app_name" android:icon="@drawable/icon">

并将此行添加到Strings.xml:

<string name="crash_toast_text">Ooooops ! I crashed, but a report has been sent to my developer to help fix the issue !</string>

实际上,当myApplication崩溃并且它没有向我的服务器发送任何消息时,没有toast消息。这是我的剧本:

reportpath.php:

<?php    
    $fileName = date('Y-m-d_H-i-s').'.txt';
    $file = fopen($fileName,'w') or die('Could not create report file: ' . $fileName);
    foreach($_POST as $key => $value) {
      $reportLine = $key." = ".$value."\n";
      fwrite($file, $reportLine) or die ('Could not write to report file ' . $reportLine);
    }
    fclose($file);
?>

有什么建议吗?

已编辑:我在ReportApp.java中测试了另一种方式:

ReportApp.java:

使用

public class ReportApp extends org.qtproject.qt5.android.bindings.QtApplication 

而不是

public class ReportApp extends Application

但它也不起作用。

0 个答案:

没有答案