如何在生成的 apk 文件中记录错误
How can I Log Error in a generated apk file
我已经为 android 应用程序生成了 apk,但不知道如何跟踪日志文件。
我的应用程序在构建期间 运行ning 和 运行,但是在生成 apk 文件时它崩溃了。
我需要帮助来跟踪 apk 文件的错误。
您可以将日志和异常情况写入一个文件,稍后可以查看该文件
或者可以 email/post 在文件
的服务器上
您还可以在项目中添加日志事件 - Firebase - Google 库,这是长期维护应用程序的好方法
另外使用像 Crashlitycs 这样的崩溃报告工具也是一个不错的选择。
您需要创建一个帐户并将 API 密钥放入您的应用程序中。然后初始化 Crashlitycs,现在,每次您的应用程序崩溃时,它都会发送一份报告,您可以跟踪它们,即使它们按 API 级别和应用程序版本分组。
根据this guide要走的路是:
将工具包添加到您的 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>"
/>
最后初始化 Crashlitycs:
Fabric.with(this, new Crashlytics());
我已经为 android 应用程序生成了 apk,但不知道如何跟踪日志文件。 我的应用程序在构建期间 运行ning 和 运行,但是在生成 apk 文件时它崩溃了。
我需要帮助来跟踪 apk 文件的错误。
您可以将日志和异常情况写入一个文件,稍后可以查看该文件 或者可以 email/post 在文件
的服务器上您还可以在项目中添加日志事件 - Firebase - Google 库,这是长期维护应用程序的好方法
另外使用像 Crashlitycs 这样的崩溃报告工具也是一个不错的选择。
您需要创建一个帐户并将 API 密钥放入您的应用程序中。然后初始化 Crashlitycs,现在,每次您的应用程序崩溃时,它都会发送一份报告,您可以跟踪它们,即使它们按 API 级别和应用程序版本分组。
根据this guide要走的路是:
将工具包添加到您的 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>"
/>
最后初始化 Crashlitycs:
Fabric.with(this, new Crashlytics());