Monday, 21 December 2020

java.lang.RuntimeException: Unable to create application com.app.MyApp: java.lang.NullPointerException: FirebaseCrashlytics component is not present

Getting this crash on only release build with r8 enabled on migrating from crashlytics to firebase SDK and upgrading gradle plugin version

Note : I have multidex dependencies defined and set in build.gradle and also in the application class. This happens only when i upgrade my gradle plugin version from 3.5 to 4.1

I am using firebase-crashlytics version

implementation 'com.google.firebase:firebase-crashlytics:17.0.0'

Grade plugin version

classpath 'com.android.tools.build:gradle:4.0.1'

Crashlytics gradle plugin version

classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'

Also I am getting warning in the logcat for

W/ComponentDiscovery: Class com.google.firebase.crashlytics.CrashlyticsRegistrar is not an found.
    java.lang.ClassNotFoundException: com.google.firebase.crashlytics.CrashlyticsRegistrar

 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.crashlytics.CrashlyticsRegistrar" on path: DexPathList


W/ComponentDiscovery: Class com.google.firebase.auth.FirebaseAuthRegistrar is not an found.
    java.lang.ClassNotFoundException: com.google.firebase.auth.FirebaseAuthRegistrar

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.auth.FirebaseAuthRegistrar" on path: DexPathList

W/ComponentDiscovery: Class com.google.firebase.database.DatabaseRegistrar is not an found.
    java.lang.ClassNotFoundException: com.google.firebase.database.DatabaseRegistrar

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.database.DatabaseRegistrar" on path: DexPathList

To get rid of the above warning I added the following in android manifest under application tag

 <service android:name="com.google.firebase.components.ComponentDiscoveryService" >
      <meta-data
          android:name="com.google.firebase.components:com.google.firebase.auth.FirebaseAuthRegistrar"
          android:value="com.google.firebase.components.ComponentRegistrar" />
      <meta-data
          android:name="com.google.firebase.components:com.google.firebase.database.DatabaseRegistrar"
          android:value="com.google.firebase.components.ComponentRegistrar"/>
      <meta-data
          android:name="com.google.firebase.components:com.google.firebase.crashlytics.CrashlyticsRegistrar"
          android:value="com.google.firebase.components.ComponentRegistrar"/>

    </service>

Still no luck with it. After doing all these I see this

java.lang.RuntimeException: Unable to create application com.app.MyApp: java.lang.NullPointerException: FirebaseCrashlytics component is not present

NPE when I try to access

FirebaseCrashlytics.getInstance();


from java.lang.RuntimeException: Unable to create application com.app.MyApp: java.lang.NullPointerException: FirebaseCrashlytics component is not present

No comments:

Post a Comment