如何在生成的apk文件中记录错误

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

我为Android应用程序生成了apk但无法弄清楚如何跟踪日志文件。我的应用程序在构建和运行期间运行,但是在生成apk文件时它崩溃了。

我需要帮助来跟踪apk文件的错误。

java android android-studio apk
2个回答
0
投票

使用像Crashlitycs这样的崩溃报告工具也是一个不错的选择。

您需要创建一个帐户并将API密钥放在您的应用中。然后启动Crashlitycs,现在,每次你的应用程序崩溃它都会发送一个报告,你可以跟踪它们,即使它们按API级别和应用程序版本分组。

this guide说,要走的路是:

将Kit添加到build.gradle

buildscript {
  repositories {
    maven { url 'https://maven.fabric.io/public' }
  }

  dependencies {
    // These docs use an open ended version so that our plugin
    // can be updated quickly in response to Android tooling updates

    // We recommend changing it to the latest version from our changelog:
    // https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
    classpath 'io.fabric.tools:gradle:1.+'
  }
}

然后在你的应用程序级别gradle中:

// Put Fabric plugin after Android plugin
apply plugin: 'io.fabric'

repositories {
  maven { url 'https://maven.fabric.io/public' }
}

并添加依赖项:

  compile('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
    transitive = true;
  }

在您的清单中,添加INTERNET PERMISSION并使用您的API KEY添加此元数据:

  <meta-data
      android:name="io.fabric.ApiKey"
      android:value="<FABRIC_API_KEY>"
  />

最后用以下内容初始化Crashlytics:

  Fabric.with(this, new Crashlytics());

0
投票

您可以在文件中编写日志和例外,稍后可以检查该文件,也可以在服务器上通过电子邮件发送/发布该文件

您还可以在项目中添加日志事件 - Firebase - Google库,这是一种长期维护应用程序的好方法

https://firebase.google.com/docs/analytics/android/events

© www.soinside.com 2019 - 2024. All rights reserved.