Android:如何在Google Play开发者控制台中获取有关已捕获例外的信息?

问题描述 投票:2回答:3

当部署在Google Play商店中的应用崩溃时,您会看到这些崩溃报告。假设我有使用Log.e捕获和记录的异常,有没有办法以任何方式查看这些异常?换句话说:当我想查看对我的工作流程而言真正重要的错误时,是否只能在Google Play开发者控制台中查看这些例外情况,以便在应用内投放RuntimeException以使用户意图崩溃? (那真是太愚蠢了)。

背景:我目前正在实施应用内结算。实际上有很多阶段可能会在购买过程中发生可能的异常。如果客户与我联系并询问购买流程无效的原因,我应该如何知道Google Play Developer Console中是否有任何信息?

android google-play in-app-purchase in-app-billing
3个回答
3
投票

你可以使用Firebase Crashlytics

Firebase Crashlytics是一款轻量级的实时崩溃记录器,可帮助您跟踪,确定优先级并解决影响应用质量的稳定性问题。 Crashlytics通过智能地对崩溃进行分组并突出显示导致崩溃的情况,从而为您节省故障排除时间。

关键能力

  • 策划崩溃报告 Crashlytics将崩溃的崩溃综合成可管理的问题列表,提供上下文信息,并突出崩溃的严重性和普遍性,以便您可以更快地查明根本原因。
  • 增强的环境信息 Crashlytics允许您按操作系统,版本,硬件配置等过滤报告。了解您的应用是否在特定制造商的设备上,某些API版本甚至是特定的屏幕方向上更频繁地崩溃。
  • 实时警报 获取可能需要立即关注的新问题,回归问题和不断增长的问题的实时警报。

Get started with Firebase Crashlytics


1
投票

你可以使用Fire base crash report service.i附上了codelabs示例代码(官方文档)。 sample code


1
投票

你可以在技术上使用Crashlytics或HockeyApp,但它可能无法帮助你,因为它只会在应用程序崩溃时触发。我的意思是这很好,但问题是如果用户有问题并且应用程序没有崩溃(购买过程没有完成)。您可以通过以下方式处理此问题(我在我的应用程序中实现了此方法):

  • 在用户设备上创建一个日志文件(注意它将需要写入存储的权限)
  • 将该日志发送到您的电子邮件地址,它将包含每个log.e,log.d,log.it等,它将帮助您重现一个错误

码:

  public static void sendLog(Context context) {
    //set a file
    Date datum = new Date();
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
    String fullName = df.format(datum) + "appLog.txt";
    File file = new File(Environment.getExternalStorageDirectory(), fullName);

    //clears a previous log
    if (file.exists()) {
        file.delete();
    }
    //write log to file
    int pid = android.os.Process.myPid();
    try {
        String command = String.format("logcat -d -v threadtime *:*");
        Process process = Runtime.getRuntime().exec(command);

        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
        StringBuilder result = new StringBuilder();
        String currentLine = null;
        while ((currentLine = reader.readLine()) != null) {
            if (currentLine != null && currentLine.contains(String.valueOf(pid))) {
                result.append(currentLine);
                result.append("\n");
            }
        }
        FileWriter out = new FileWriter(file);
        out.write(result.toString());
        out.close();
        sendEmail(context, file);
    } catch (IOException e) {
        e.printStackTrace();
    }


    //clear the log

    try {
        Runtime.getRuntime().exec("logcat -c");
    } catch (IOException e) {
        e.printStackTrace();
    }


}

发送文件到电子邮件:

private static void sendEmail(Context context, File file) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"XXXXXXXXXX ENTER EMAIL"});
    intent.putExtra(Intent.EXTRA_SUBJECT, "Log Report");
    intent.putExtra(Intent.EXTRA_TEXT, "Add description:");
    if (!file.exists() || !file.canRead()) {
        Toast.makeText(context, "Attachment Error", Toast.LENGTH_SHORT).show();
        return;
    }
    Uri uri = Uri.parse("file://" + file);
    intent.putExtra(Intent.EXTRA_STREAM, uri);
    context.startActivity(Intent.createChooser(intent, "Send email..."));
}
© www.soinside.com 2019 - 2024. All rights reserved.