我正在尝试在我的 Qt-Android 项目中使用ARCA作为错误报告器。我阅读了本教程并将 .JAR 文件添加到我的项目中,在我的项目中创建了新类 ( ReportApp.java )。
报告应用程序.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 消息。这是我的脚本:
报告路径.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 中测试了另一种方式:
报告应用程序.java:
利用
public class ReportApp extends org.qtproject.qt5.android.bindings.QtApplication
代替
public class ReportApp extends Application
但它也不起作用。