After migration from Fabric to FirebaseCrashlytics tests failing - android

Recently we attempted to migrate from Fabric.io to FirebaseCrashlytics. Followed steps as described in documentation https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android
Updated google-service.json files
Replaced fabric.io dependencies with Firebase Crashlytics
Updated code and enabled collection only when prod builds with setCrashlyticsCollectionEnabled(!BuildConfig.DEBUG)
Updated proguard rules
After that, we try to run our test suite when we noticed that it is taking much longer than usual and in the end it failed with many tests reporting OutOfMemoryError. This set of tests run just fine with Fabric dependencies.
Does anybody had or run into a similar problem?

Documentation says Fabric Crashlytics SDK uses a ContentProvider to initialize itself. So it is too late call setCrashlyticsCollectionEnabled function in your Application Code.
Fabric's API key is no longer used by the new SDK. Instead, Crashlytics now uses your app’s google-services.json file to associate your app with your Firebase project and retain your historic crash data. If you have an io.fabric.ApiKey declared in your AndroidManifest.xml file, remove it.
If you want to disable automatic crash reporting and enable it only
for select users, use the Android meta-data tag in your
AndroidManifest.xml file. Then, you can enable crash reporting using
the new setCrashlyticsCollectionEnabled instance method.
https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android#firebaseno_longer_works_with_the_fabric_sdk
So you need to disable data collection in your manifest. In order to do that you need to add firebase_crashlytics_collection_enabled meta-tag to your manifest.
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
https://github.com/firebase/firebase-android-sdk/blob/5440af41f0d15ff1358038dc31fcd1d4eac0a89c/firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/internal/common/DataCollectionArbiter.java#L74
You might want to inject build variables to manifest file since you only want to disable Crashlytics in your test builds. See the link down below.
https://developer.android.com/studio/build/manifest-build-variables.html

OK, I do have update on this. We just updated libraries to latest version that was recently published and issue looks to be sorted
com.google.firebase:firebase-crashlytics-gradle:2.2.0 instead of 2.1.0
com.google.firebase:firebase-crashlytics:17.1.0 instead of 17.0.0
which original article was published with

Related

E/FirebaseCrashlytics: Failed to retrieve settings from https://firebase-settings.crashlytics.com/spi/v2/platforms/android/gmp/XXXX/settings

I tried new Firebase Crashlytics SDk after migrating from Fabric and seem to run into a weird issue.
Crash logs are not captured in dashboard after upgrading firebase-crashlytics to 17.0.0 and I get this error in log:
E/FirebaseCrashlytics: Failed to retrieve settings from https://firebase-settings.crashlytics.com/spi/v2/platforms/android/gmp/XXXX/settings
and I followed all instructions from firebase console quickstart guide. Please help me if any one have faced similar issue.
In my case, I had migrated the release version but I guess I never enabled Crashlytics on the Firebase console for the debug variant.
A simple mistake, but putting it here in case it helps out someone else.
If you enabled multiple apps in single project, ensure you choose the correct one (left drop down menu choose the correct project which hold the multiple apps, right drop down menu choose the correct running app). I made such mistake and keep looking on the wrong app page and enabling Crashlytics on the wrong app and of course I get that error "Failed to retrieve settings from https://...:
In my case, There was a legacy firebase project which using same package name of app. When I deleted legacy firebase project and It's works like a charm!
Firebaser here -
We often see these kinds of errors after upgrading due to some sort of configuration error when you were switching out your dependencies. Did you make sure to follow all the steps in this guide?
You may also want to enable Crashlytics debug logging and force a test crash to see if the logs give you any other output. And it may help to edit your original question with your Gradle files and any other relevant Crashlytics setup.
Same problem here with 17.2.1, one of my app flavours didnt't work throwing above error. Removing current apps and re-adding them in firebase project settings solved the problem for me.
We had an issue with the firebase apps and had to re-create the android app on firebase. This meant I had to update the google-services.json file.
After doing this, firebase remote config worked but analytics and crashlytics did not.
Turns out android studio was using-an auto generated file values.xml. This contained
<string name="google_app_id" translatable="false">1:xxxxxxx:android:yyyyyyyy</string>
The yyyyyy part of it was still using the old value from the previous google-services.json file. Deleting this file for all flavors, debug and release builds, coupled with an invalidate caches + restart
might do the trick, but just to be safe, what fixed it for me was:
commenting all the firebase libs from all gradle files
syncing gradle
project will not compile at this points since it cant find Firebase dependencies
invalidate caches + restart
uncomment firebase libs in all gradle files
sync gradle
run app and check if firebase crashlytics works
I am using Android studio 4.1.2
If you have changed the google-services.json file, i.e changed it with a one from a different project, you should do the following:
Comment out all the crashlytics dependencies in the gradle files
Build the app
Invalidate cache and restart
Uncomment crashlytics dependencies and rebuild app
This should fix the problem if it's caused by cached values from the previous json file for crashlytics.

Problem with adding Firebase Crashlytics in Xamarin Android project

I have some problem with adding Firebase Crashlytics in Xamarin Android project.
I created an empty android project in visual studio. Then I registered the application in google firebase console. Then downloaded google-services.json and put it in the project.
for this file set the build in googleservicejson mode.
Before that, I added the following nugget packages:
Xamarin.Android.Crashlytics
Xamarin.Android.Crashlytics.Answers
Xamarin.Android.Crashlytics.Beta
Xamarin.Android.Crashlytics.Core
In OnCreate method, I added the following code:
Fabric.Fabric.With (this, new Crashlytics.Crashlytics ());
Crashlytics.Crashlytics.HandleManagedExceptions ();
Also I add this meta data in AndroidManifest.xml
<meta-data android:name="io.fabric.ApiKey" android:value="firebase api key" />
Then I added this in strings.xml
<string name="com.crashlytics.android.home.firebaseandroid">33</string>
where home.firebaseandroid is my apk name
After cleaning and rebuild, when I launch the application it throw this exception:
Fabric.Services.Concurrency.UnmetDependencyException: 'This app relies on Crashlytics. Please sign up for access at https://fabric.io/sign_up,
install an Android build tool and ask a team member to invite you to this app's organization.'
As I understand, the application is looking for an api key for the Fabric, but I only have the api key from firebase.
Has anyone had a same problem?
Advise in what direction to look, please.
Thanks in advance.
If you're using a google services file, then you should not be specifying API keys in your AndroidManifest. The google services file already contains the API key that Crashlytics SDK is looking for.
If you want to try something else, see my comment on this issue here: https://github.com/xamarin/XamarinComponents/issues/760#issuecomment-579010612
This is the workaround I've found at that time (yes, I know it is not the last version, please keep reading):
I've fixed the issue at least for me. It seems that the issue was caused by
dependency interactions.
For anybody struggling with this, I've got it working by using exactly
the following versions:
Xamarin.Android.Crashlytics 2.9.4.1
Xamarin.Android.Crashlytics.Answers 1.4.2
Xamarin.Android.Crashlytics.Beta 1.2.9
Xamarin.Android.Crashlytics.Core 2.6.3 Xamarin.Android.Fabric 1.4.3
Xamarin.Build.Download 0.4.11
Installing Crashlytics will install Xamarin.Build.Download 0.7.1 as a
dependency, but (at least for me) it is not possible to get a proper
build anymore with that version. So this package should be downgraded
after it is installed.
Having said that; you must be aware of the imminent deprecation of this Crashlytics version based on Fabric, right?
All of us were received a mail from Google informing that:
We are writing to let you know that the Fabric Crashlytics SDK is now deprecated and will continue reporting your app's crashes until
November 15, 2020. After this date, the Fabric Crashlytics SDK and
beta versions of the Firebase Crashlytics SDK will stop sending crash
reports for your app.What happened?
We are replacing Fabric Crashlytics SDKs and beta versions of the Firebase Crashlytics SDKs with the generally available Firebase
Crashlytics SDKs.What's Next?
To continue getting crash reports in the Firebase console, make sure to upgrade your apps to the Firebase Crashlytics SDK versions
17.0.0+ for Android, 4.0.0+ for iOS, and 6.15.0+ for Unity before November 15, 2020.Android
So everything is going to change soon, and you shouldn't use the Fabric solution anymore, especially for new projects.
You can found the new official nuget package here, but it is a preview (the xamarin team is working on this, I guess, but they are dangerously near the deadline -as we all):
https://www.nuget.org/packages/Xamarin.Firebase.Crashlytics/117.0.0-preview02
This is the official repository issue to add comments:
https://github.com/xamarin/XamarinComponents/issues/956
I'm currently migrating my project to this new Crashlytics version, and one thing to keep in mind is that you need to use AndroidX (that was a problem for me, I'm working on an old project's maintenance, and the migration to AndroidX is not ready yet)
When you'll add this new package and the google-services.json you will need to change the following in your old code:
Every CrashLytics.Crashlytics reference will be just FirebaseCrashlytics.
No initialization is needed, you can get the FirebaseCrashlytics.Instance anywhere
To log an exception you will need to use the RecordException method instead of the old LogException
SetUserIdentifier is changed to SetUserId, and SetUserName is no longer there
There is no method to crash on purpose anymore, so now you have to simply throw any exception you want if you wanna test your implementation
Maybe I'm missing something, but basically, that's all.

Android Firebase Crashlytics displays no crashes for Internal Test Track

I have firebase crashlytics integrated on a new android app and its currently deployed on internal test track only. I see the internal version tags show in crashlytics but I see no crashes for that those versions.
Are crashlytics logs not available for internal test track? Would they work for alpha (closed) test track?
AndroidManifest.xml has:
<meta-data android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
Initializing as:
Fabric.with(Fabric.Builder(this)
.kits(Crashlytics(), CrashlyticsNdk())
.build())
in the Application subclass.
The setup was done following the instructions here: https://firebase.google.com/docs/crashlytics/get-started#android
Also added:
implementation 'com.crashlytics.sdk.android:crashlytics-ndk:2.0.5'
to the build.gradle for crashlytics ndk support. (Assuming the symbols are uploaded automatically with cmake build)
Currently, Fabric was deprecated.
So you need to other way to initialize Crashlytics.
I added a link that would help.
It shows the way to test Crashlytics internally with adb.
https://firebase.google.com/docs/crashlytics/test-implementation?authuser=1&platform=android

CrashlyticsMissingDependencyException when integration with MarmaladeSDK and Firebase

I tried to use Crashlytics instead of FirebaseCrash Reporting. I added all relevant Libraries: crashlytics, fabric, answer, beta and everything compiled and started properly on my Android device. I'm working with MarmaladeSDK which has no AndroidStudio/gradle integration. I need to add every lib by myself to the build system (jars, Android Manifest, Resources mainly).
I have two issues:
Crashlytics is not started automatically. I had to call
Fabric.with(this, new Crashlytics()); Which aar library is reponsible for starting the crashlytics services?
I got an CrashlyticsMissingDependencyException with the error message:
This app relies on Crashlytics. Please sign up for access at
https://fabric.io/sign_up, install an Android build tool and ask a team
member to invite you to this app's organization.
How does chrashlytics gets the knowledge that Firebase is the new destination and that there is no need to register at the fabric.io website?
I have no idea what apply plugin:'io.fabric' does? Can I mimic this behaviour even without Android studio? My main issue is probably that gradle does some magic which I don't understand and I assume that apply plugin:'io.fabric' could be responsible for that.

Does Firebase's "Crash Reports" report automatically on a crash?

Let's say I have this:
String x = i;
and i is null, and then, I get a NullPointerException. I didn't add any Firebase Logs, so will this be reported? I've setup the SDK and everything, however, when I tried, it didn't report anything, but it says reports may take up to 24 hours. So, will it be reported?
As per Firebase doc to Create your first error answer is Yes
Firebase Crash Reporting automatically generates reports for fatal errors (or uncaught exceptions).
But Make sure you follow below steps for Set up Crash Reporting for your app:
If you haven’t already, set up Firebase for your Android project.
In the Firebase console, add your app to your Firebase project.
Add the dependency for Crash Reporting to your app-level build.gradle file:
compile 'com.google.firebase:firebase-crash:9.4.0'
Before proceeding, check if your app manifest defines an Application object. If that is the case, check the Known issues section.
I hope its helps you.

Categories

Resources