【问题标题】:Firebase Crashlytics is not showing my errorsFirebase Crashlytics 没有显示我的错误
【发布时间】:2018-08-29 11:30:28
【问题描述】:

我试图让 Crashlytics 工作,但即使我遵循了所有步骤,我似乎仍然没有在 Crashlytics 中看到任何错误。

你能看看吗?

这是我用来启动崩溃的代码:

Crashlytics.getInstance().crash(); // Force a crash

我的应用程序 Gradle:

apply plugin: 'com.android.application'

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            lintOptions {
                disable 'MissingTranslation'
            }
        }
    }
    buildToolsVersion '27.0.3'
}

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

repositories {
    mavenCentral()
}
apply plugin: 'io.fabric'

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    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:25.+'
    implementation 'com.android.support:design:25.+'
    implementation 'com.android.support:support-v4:25.+'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.roughike:bottom-bar:2.3.1'
    testImplementation 'junit:junit:4.12'

    implementation 'com.google.firebase:firebase-core:16.0.3'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.3'
    implementation 'com.firebaseui:firebase-ui-auth:4.1.0'

    // Required only if Facebook login support is r6equired
    implementation 'com.facebook.android:facebook-android-sdk:4.27.0'

    // Required only if Twitter login support is required
    implementation("com.twitter.sdk.android:twitter-core:3.0.0@aar") { transitive = true }

    implementation 'com.google.firebase:firebase-storage:16.0.1'

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

    //compile 'com.google.firebase:firebase-crash:16.0.0'

    // Displaying images
    implementation 'com.github.bumptech.glide:glide:3.7.0'

    //implementation 'com.google.android.gms:play-services:15.0.0'

    implementation 'com.google.android.gms:play-services-auth:16.0.0'
    implementation 'com.google.android.gms:play-services-base:15.0.1'
    implementation 'com.google.android.gms:play-services-identity:15.0.1'
    implementation 'com.google.android.gms:play-services-analytics:16.0.3'
    implementation 'com.google.android.gms:play-services-gcm:15.0.1'
    implementation 'com.google.android.gms:play-services-vision:15.0.2'

    implementation 'com.github.amlcurran.showcaseview:library:5.4.3'

    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'

    implementation files('libs/YouTubeAndroidPlayerApi.jar')
}

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.3.1'
            }
        }
    }
}

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

我的 Build Gradle(我还从 Firebase 设置中获取了一个新的 google-services.json 文件):

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

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:4.0.1'
        classpath 'io.fabric.tools:gradle:1.25.4'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

这是我的清单

<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="blah">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CLEAR_APP_CACHE" />

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />

    <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/SplashScreenTheme">
        // metadata for Facebook login
        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id"
            tools:replace="android:value" />
        <activity
            android:name=".SplashScreen"
            android:screenOrientation="portrait">
            -
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MainActivity"
            android:configChanges="orientation|screenSize"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.TransNav" />
        <activity
            android:name=".QRCodeScannerActivity"
            android:theme="@style/Theme.TransNav" />
        //Facebook activities for Facebook login
        <activity
            android:name="com.facebook.FacebookActivity"
            android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:label="@string/app_name" />
        <activity
        android:name="com.facebook.CustomTabActivity"
        android:exported="true">

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="@string/fb_login_protocol_scheme" />
        </intent-filter>
    </activity>

        <meta-data
            android:name="com.google.android.gms.vision.DEPENDENCIES"
            android:value="barcode" />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/ic_logo_without_text" />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_color"
            android:resource="@color/white" />
        <meta-data
            android:name="io.fabric.ApiKey"
            android:value="blh"/>

        <service android:name=".MyFirebaseInstanceIDService">

            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>

        <service android:name=".MyFirebaseMessaging">
            -
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
    </application>
</manifest>

【问题讨论】:

    标签: java android firebase crashlytics


    【解决方案1】:

    尝试启用调试模式,如文档 here 中所述。

    1) 将这些行添加到清单中

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

    2) 初始化 Crashlytics 时,启用调试模式。

    final Fabric fabric = new Fabric.Builder(this)
        .kits(new Crashlytics())
        .debuggable(true)  // Enables Crashlytics debugger
        .build();
    Fabric.with(fabric);    
    

    【讨论】:

    • 我也尝试了你提到的所有步骤,但我仍然看不到 Crashlytics 中的任何错误。
    • 你是从 firebase 还是从独立的 fabric sdk 使用它
    • 我用过 Firebase
    • 你已经为firebase添加了json文件吗?
    • 是的。我什至回到 Firebase 并使用谷歌服务下载了一个新的全新 json 文件
    【解决方案2】:

    有时,Firebase Crashlytics 需要一些时间来注册崩溃。稍等片刻,如果您按照正确的步骤操作,我相信过一段时间就会出现崩溃。

    编辑

    按照以下步骤操作:

    1. 将 Crashlytics 存储库和依赖项添加到您的项目级 build.gradle 文件。

      maven {
         url 'https://maven.fabric.io/public'
      }
      
      dependencies {
      // ...
      classpath 'io.fabric.tools:gradle:1.25.4'
      }
      
      allprojects {
          repositories {
      
        maven {
         url 'https://maven.google.com/'
            }
          }
      }
      

    此外,请检查 Crashlytics 需要 Google 服务插件版本 3.1.2 或更高版本。检查项目的 build.gradle 依赖项中的 com.google.gms:google-services 版本号。

    2.) 将 Crashlytics 依赖项添加到您的 应用级 build.gradle

        apply plugin: 'io.fabric'
        dependencies {
        // ...
        implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
        }
    

    将此作为您的强制崩溃按钮:

        Button crashButton = new Button(this);
        crashButton.setText("Crash!");
        crashButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
        Crashlytics.getInstance().crash(); // Force a crash
    }
    });
    
       addContentView(crashButton, new ViewGroup.LayoutParams(
        ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.WRAP_CONTENT));
    

    【讨论】:

    • 感谢您的评论。我已经等了几天,崩溃仍然没有出现。你知道可能是什么问题吗?
    • @Emma 试试这些步骤。我相信这会有所帮助。
    • 我尝试了所有这些步骤,但在 Crashlytics 中仍然看不到任何错误。
    猜你喜欢
    • 2019-05-28
    • 1970-01-01
    • 2019-07-17
    • 1970-01-01
    • 1970-01-01
    • 2021-09-23
    • 1970-01-01
    • 1970-01-01
    • 2020-05-23
    相关资源
    最近更新 更多