Why is Fabric not initialized? java.lang.IllegalStateException: Must Initialize Fabric before using singleton()

后端 未结 8 621
误落风尘
误落风尘 2021-02-06 22:26

I set up Firebase Crashlytics according to Get started with Firebase Crashlytics for my Android app (using Android studio 3.1.3). On my own device as well as on the Emulator, ev

相关标签:
8条回答
  • 2021-02-06 22:40

    If you used android:process, then automatic initialization wouldn't work because it works by using a content provider in your manifest. In that case, you'll have to manually initialize Crashlytics.

    0 讨论(0)
  • 2021-02-06 22:43

    If you migrated from Fabric.io to Firebase, there must be some lines you need to DELETE from AndroidManifest.xml

            <!-- Fabric.io Analytics key -->
            <meta-data
                android:name="io.fabric.ApiKey"
                android:value="49yy995568140ee22uio128e00450bd99603fd43" />
    

    With those lines, the Crashlytics plugin can NOT be initialized correctly by Firebase.

    0 讨论(0)
  • 2021-02-06 22:52

    This error had me beat on an Ionic 4 build. I have installed the Cordova firebaseX module, and this error occurred.

    From reading the debug log I managed to see that the firebase crashlytics collection was missing a bool. In the androidmanifest I found this line and simply changed the value to a bool for a hot fix. I put in 'true' - and the error is gone.

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

    So for anyone out there was this error on Ionic platform. Look in the androidmanifest file for the above meta line.

    0 讨论(0)
  • 2021-02-06 22:57

    In my case, The below checks helped to get rid of the error.

    If you find code like below in your manifest, set it to true or remove it since it's true by default.

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

    Also incase if the value is being pulled in from your build.gradle, check which buildType its in and consider not invoking any Crashlytics functions under that buildType.

    Example: build.gradle

    android{
    
        ...
    
       buildTypes {
            debug{
                manifestPlaceholders = [enableCrashReporting:"false"]
            }
            release {
                manifestPlaceholders = [enableCrashReporting:"true"]
            }
       }
    }
    

    In this case you should have your Crashlytics calls wrapped like this -

    if(!BuildConfig.DEBUG){
       ...
       Crashlytics.setUserIdentifier(...)
       ...
    }
    
    0 讨论(0)
  • 2021-02-06 22:59

    When you are using Firebase Crashlytics, you don't need to do any Fabric initialization. Everything is done automatically.

    But if you want to do any custom logging, via (for example) Crashlytics.log("Custom log"), you need to have FirebaseCrashlytics enabled in your manifest. Check the manifest if you have something like that:

    <meta-data
        android:name="firebase_crashlytics_collection_enabled"
        android:value="${crashlyticsEnabled}" />
    

    ${crashlyticsEnabled} can be set to true or false or via you app level build.gradle. This is typically used to disable Firebase Crashlytics when you are debugging the app.

    0 讨论(0)
  • 2021-02-06 23:03

    You need to initialize Crashlytics in your application's onCreate

    import android.app.Application;
    
    import com.crashlytics.android.Crashlytics;
    
    import io.fabric.sdk.android.Fabric;
    
    public class TestApplication extends Application {
        @Override
        public void onCreate() {
            super.onCreate();
            Fabric.with(this, new Crashlytics());
        }
    }
    
    0 讨论(0)
提交回复
热议问题