gpt4 book ai didi

android - Fabric 不发送崩溃报告

转载 作者:行者123 更新时间:2023-11-29 02:25:20 27 4
gpt4 key购买 nike

在 Android 中使用结构发送崩溃报告。在 MainActivity 的 OnCreate 上使用了 throw RuntimeException("This is a crash");。如果在按钮点击监听器或任何其他 Activity oncreate 中使用崩溃报告,则会上传其他崩溃报告,它不会上传崩溃报告。这是

  @Override   protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
}

Gradle 版本 4.4安卓插件版本 3.1.4

list

    <meta-data
android:name="firebase_analytics_collection_enabled"
android:value="false" />

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

应用级渐变

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

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

android {
compileSdkVersion 27
// buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.example.first"
minSdkVersion 19
targetSdkVersion 27
versionCode 45
versionName "2.1.6"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}


buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'proguard-fresco.pro'


}
}

configurations {
all {
exclude group: 'org.json', module: 'json'
}
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:customtabs:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:design:27.1.1'

implementation 'com.razorpay:checkout:1.4.9'
implementation "com.razorpay:razorpay-java:1.3.8"

implementation 'com.facebook.android:facebook-android-sdk:4.16.1'
implementation 'com.facebook.fresco:fresco:1.9.0'
// implementation 'com.github.freshdesk:hotline-android:1.2.3'
implementation 'com.github.freshdesk:freshchat-android:1.5.2'


// implementation 'com.google.android.gms:play-services:15.0.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'io.branch.sdk.android:library:2.18.1'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
testImplementation 'junit:junit:4.12'

implementation 'com.google.firebase:firebase-messaging:17.3.2'

implementation 'com.google.firebase:firebase-crash:16.2.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
transitive = true;
}
implementation 'com.google.firebase:firebase-core:16.0.3'
}

apply plugin: 'com.google.gms.google-services'

项目级gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
google()
maven {
url 'https://maven.fabric.io/public'
}
}

dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.1.0'
// classpath 'io.fabric.tools:gradle:1.26.0'
classpath 'io.fabric.tools:gradle:1.25.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
maven {
url 'https://jitpack.io' }
mavenCentral()
jcenter()
maven {
url 'https://maven.google.com/'
}

}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

最佳答案

 @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
setContentView(R.layout.activity_main);

throw new RuntimeException("This is a crash");
}

Manifest

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".activity.MainActivity"
android:label="@string/title_activity_main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="io.fabric.ApiKey"
android:value="4*************************" />
</application>

<uses-permission android:name="android.permission.INTERNET" />

Build Gradle

buildscript {

repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'io.fabric.tools:gradle:1.+'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

Gradel Module App

    apply plugin: 'com.android.application'
apply plugin: 'io.fabric'


android {
........
........
}

dependencies {
........
........

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

编辑2

导致测试崩溃

您可以通过抛出未捕获的异常来检查是否已成功添加崩溃报告,例如:

throw new RuntimeException("This is a crash");

崩溃是在您的应用程序重新打开后发送的,因此请务必将此行放在您的 Application 类之外,或者您的启动 Activity 的 onCreate() 方法之外;添加一个按钮来触发崩溃通常效果很好。

我们实时处理崩溃。如果我们检测到崩溃是由新问题引起的,它将在您的仪表板上显示为新问题。如果现有问题再次出现,该问题的崩溃计数器将增加,新崩溃的信息将包含在该问题中。

疑难解答

如果您没有看到崩溃,请检查以下常见的延迟原因:

  1. 确保我们的 SDK 初始化行在所有其他第 3 方之后SDK
  2. 强制崩溃,然后重新启动该应用。
  3. 如果您使用我们的 Crashlytics.getInstance().crash() 方法来测试目的,确保它不在你的 onCreate 方法中启动 Activity
  4. 检查您的网络连接,确保其稳定且可用发送崩溃。请记住,不能保证有异常(exception)导致崩溃。完整的代码路径,包括系统中的代码图书馆在这里很重要。设备和模拟器以及不同的操作系统关于哪些类型的错误会有不同的行为实际上会导致崩溃,尤其是当涉及 UI 线程时。

关于android - Fabric 不发送崩溃报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52565474/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com