How to completely disconnect an Android app from Firebase (in Android studio) - android

I want to completely disconnect my app from Firebase. This question has been asked several times (e.g here). Most of the answers focus on disconnecting an app from Firebase within the Firebase console and not within Android studio.
After disconnecting my app from the Firebase console. Everytime I try to reconnect the app to another Firebase project, an error balloon pops up stating that the app is already part of a Firebase project. I know this behaviour occurs because some files from the old Firebase project are still present. How do I get rid of them?

Try these steps to remove Fire-base from Android Studio project.
Delete google-services.json file from the Project (Find the file by Project view)
Remove dependencies from Project-level build.gradle (/build.gradle)
buildscript {
dependencies {
// Remove this line
classpath 'com.google.gms:google-services:4.2.0'
}
}
Remove all the Fire-base related dependencies from the project App-level build.gradle (//build.gradle) file
dependencies {
// Remove this line
implementation 'com.google.firebase:firebase-core:17.0.0'
}
Remove the line below from the bottom of the App-level build.gradle (//build.gradle) file
apply plugin: 'com.google.gms.google-services'
Restart Android Studio

Try this, On the project level, delete the google-services.json file
and then sync the project

You should undo all the steps that you are instructed to perform in the manual integration. So, remove all Firebase dependencies from build.gradle, remove the Google Services plugin from the bottom of build.gradle, and remove the google-services.json file.

Try shutting down the Firebase project created with the package name of the connected application; although it doesn't delete at the same time and is scheduled for later. Don't link your android app with any other firebase app till the previous connected app has been deleted completely.

Do the following (If you want to Switch Firebase Data Sources):
In Android Studio, Go to Tools>Firebase, Choose any of the options such as Real time-database
Click Connect to Firebase.
You will get a warning that the App is already connected to Firebase.
Click okay.
Android Studio will open a Firebase console on a browser.
Choose the Firebase App you want to you want to connect to.
Done.

On the main menu, select app ,select ,google-services.json' and then right click then delete

Related

How do you create a new fabric crashlytics Instant app?

Fabric app was creating with just fine with my other apps. Wait until I clicked on Instant app when I started my new project. Now I have two packages picked up by Fabric for the same project.
I installed crashlytics on one of the packages but still the app is not created in Fabric from Android studio.
Please help resolve, its been two days now i've build and run the app several times still no fabric App.
First, Add the plugin to your android studio using below steps:
File -> Settings -> Plugins -> Select Fabric for Android Studio -> Install it
Finally, after install plugin, you can see Fabric icon in top toolbar also in right panel with fabric word select and log in,
From the fabric, menu select your project operation which will see in the panel next option(Code setup for fabric).
Repeat 3 times for those important things:
Fabric support for Google Instant Apps is not currently enabled. Contact support#fabric.io if you're interested in trying it!
Fabric support for Google Instant Apps is not currently enabled. Contact support#fabric.io if you're interested in trying it!
Fabric support for Google Instant Apps is not currently enabled. Contact support#fabric.io if you're interested in trying it!
but if you dont belive that , you can follow this 5 steps to validate it.
choose the package without .feature
add dependencies to your project/build.gradle file
add apply plugin: 'io.fabric' to your base/build.gradle file
add dependencies compile('com.crashlytics.sdk.android:crashlytics:2.9.5#aar') {
transitive = true;
} to your base/build.gradle file
add <meta-data
android:name="io.fabric.ApiKey"
android:value="your apikey" />
to your base/AndroidManifest.xml
click your Sync now

Failed to retrieve settings from https://settings.crashlytics.com/spi/v2/platforms/android/apps/

I am trying out the new Firebase/Crashlytics setup and seem to run into a weird issue.
I have one Android code base with multiple product flavors and each flavor is a separate individual app.
all of these apps are registered in Fabric (from the past)
all of these apps are added in Firebase
All linking between the two seems ok (from Fabric side as well as from Firebase side, it says that it is all linked up)
I removed the Fabric API key from the manifest file and added the appropriate plugins/dependencies etc. to both gradle files
I try to send a test crash report as per Firebase instructions.
I receive it perfectly fine on one of the product flavors, so I assume all works well.
However,
the rest of the product flavors do not send the crash report and I get this error in log:
E/Fabric: Failed to retrieve settings from https://settings.crashlytics.com/spi/v2/platforms/android/apps/package name/settings
Ok, I think I solved the problem, but the solution does not seem to be the way it should work (at least I do not think).
Go to Firebase Console > Project Settings > Account Linking > Fabric > Select the app and Unlink it
Confim in Fabric > App > Firebase - that it is unlinked
Go to Firebase > Project > Crashlytics (select the app you want) and you should now get a dialog to link your app again
Choose to link as a New Crashlytics (not existing one) and follow the directions
After that all should work fine
So basically, from Fabric>Firebase screen - there is no link visible and from Firebase>Account Linking>Fabric screen - there is also no linking visible. So no linking, but your crashes will be visible in Firebase.
This takes me a lot of time than I figured out how to migrate correctly. Actually you have two ways how to do it:
Perform clean migration without keeping crash history from Fabric Crashlytics
This way is described in Firebase Crashlytics developer guide. You have to here remove com.crashlytics.ApiKey meta-data from app manifest file.
With this way you must not link Fabric with Firebase otherwise crashes will not shown in Firebase nor Fabric console.
Link Fabric with Firebase and keep the crash history
This way is probably nowhere documented. Crucial is here to keep com.crashlytics.ApiKey meta-data in your manifest. Then you need to link Fabric Crashlytics with Firebase. You can also enable forwarding Events (formerly Answers) to Firebase Analytics. Both actions are presented in Fabric console, look for Firebase in a side menu.
All new crash reports show up in both Fabric console and Firebase console. Also this linking arrange a copying all Fabric crash report history to Firebase.
I think firebase-core artifact is not necessary here, but I added it. I'm also using Fabric Events, so with firebase-core additional app usage events was appeared in Firebase Analytics.
I had the same issue and it took me a lot of time to figure out.
I solved my problem by going to FireBase Console > [my project] > Crashlytics. In the dropdown you need to select your app. After that a wizard with three steps will show up.
Click whatever option suits you, I chose the first because it's a new app. After that the second step shows up.
Now here comes the important part. Make sure you click the link to go to the documentation! A new browser tab will open up. If you already finished the project setup like me, you can close it. After that you will automatically go to the 3rd option. Most of the time I never clicked the link because I had already completed the installation. And once I did I never noticed that the 3rd option was available because I'm at the other tab. As a result I never got to see the 3rd option.
At this point you should open your app and it will automatically connect to Firebase without any problem.
Edit: After I tried to add some other build variants I noticed that I was still getting some errors while retrieving the settings. It took me a lot of time to figure out how to solve it. The best thing I could come up with is:
switch to build variant
perform an assemble[YOUR_BUILD_VARIANT] on the gradle tab.
build > rebuild project
delete old app from device if present.
install app and open it.
Sometimes this also didn't work and I tried the same steps again one or two times and suddenly it started working...
It also helped me to enable additional debug logging for fabric and crashlytics.
adb shell setprop log.tag.Fabric DEBUG
adb shell setprop log.tag.CrashlyticsCore DEBUG
If there's network connectivity (like in Airplane mode), you will get this error even if everything is setup correctly.
You will also get:
E/Fabric﹕ Failed to retrieve settings from https://settings.crashlytics.com/spi/v2/platforms/android/apps/com.xyz/settings
W/Fabric﹕ Received null settings, skipping initialization!
To prevent Crashlytics from further crashing when logging, I do this:
boolean fabricInitialized = Fabric.isInitialized();
if (fabricInitialized) {
Crashlytics.log(someString);
}
Go to the settings of the project and add SHA-1 key for your android app.
After that redownload google-service.json to your sources.
This causes disappearing of this error
E/Fabric: Failed to retrieve settings from https://settings.crashlytics.com/spi/v2/platforms/android/apps/package name/settings
And after quite a huge delay you'll see crashes in Firebase Console.
By the way this doesn't help me with apps that were registered under one Google account, and after that moved to another account. Wiating for a response of Firebase team about this issue.
You probably forgot to add:
<meta-data
android:name="io.fabric.ApiKey"
android:value="h4132h4k324hjh4l4324h24hk21h4kj2h4" />
To your Manifest file. At least in my case, that was the reason.
In my case, the location of meta-data:io.fabric.ApiKey was wrong.
app/src/main/AndroidManifest.xml
before
<application
...>
<activity
...>
<meta-data
android:name="io.fabric.ApiKey"
android:value="xxxxxx" />
</activity>
</application>
after
<application
...>
<activity
...>
</activity>
<meta-data
android:name="io.fabric.ApiKey"
android:value="xxxxxx" />
</application>
I hope this will be of some help.
I'm finding out that I had to unregister and re-register my existing apps with Firebase after converting over to FirebaseCrashlytics.
Make sure you get your app to the following point before running it for it's initial FirebaseCrashlytics registration (console waits for initial registration), otherwise it won't register:
enter image description here
None of this is obvious!
Upgrade to the Firebase Crashlytics SDK Android & iOS
You can now set up Crashlytics in your app by using the new official Firebase Crashlytics SDK, which offers improved APIs that are more consistent with other Firebase products and more intuitive to use. This guide describes how to upgrade to the new SDK from the Fabric Crashlytics SDK. It describes the changes that come with the new APIs, the reason for the changes, and how to update your code, if required.
Android
Precondition: Migrate your app to AndroidX
1. Add a Firebase configuration file
Open your Project Settings.
Click Download google-services.json to obtain your Firebase Android config file.
Move your config file into the module (app-level) directory of your app.
2. Switch your dependencies
(project-level)/build.gradle
Deprecated From:
buildscript {
// ...
repositories {
// ...
// Remove Fabric's Maven repository.
maven { url 'https://maven.fabric.io/public' }
// Add Google's Maven repository (if it's not there already).
google()
}
dependencies {
// ..
// Add the Google Services Gradle plugin (if it's not there already).
classpath 'com.google.gms:google-services:4.3.3'
// Remove the Fabric Gradle plugin.
classpath 'io.fabric.tools:gradle:1.31.2'
}
}
To:
buildscript {
// ...
repositories {
// ...
// Add Google's Maven repository (if it's not there already).
google()
}
dependencies {
// ..
// Add the Google Services Gradle plugin (if it's not there already).
classpath 'com.google.gms:google-services:4.3.3'
// Add the Firebase Crashlytics Gradle plugin.
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.0'
}
}
(app-level)/build.gradle
Finally, add the Firebase Crashlytics SDK. In your app-level build.gradle, replace the legacy Fabric Crashlytics SDK with the new Firebase Crashlytics SDK. For an optimal experience with Firebase Crashlytics, we recommend also adding the Firebase SDK for Google Analytics to your app (make sure to add Version 17.2.3 or later in order to get real time crash-free users and breadcrumbs).
Deprecated From:
apply plugin: 'com.android.application'
// Apply the Google Services plugin (if it's not there already).
apply plugin: 'com.google.gms.google-services'
// Remove the Fabric plugin.
apply plugin: 'io.fabric'
dependencies {
// Remove the Fabric Crashlytics SDK.
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
// Recommended: Add the Google Analytics SDK.
implementation 'com.google.firebase:firebase-analytics:17.4.1'
}
To:
apply plugin: 'com.android.application'
// Apply the Google Services plugin (if it's not there already).
apply plugin: 'com.google.gms.google-services'
// Add the Firebase Crashlytics plugin.
apply plugin: 'com.google.firebase.crashlytics'
dependencies {
// Add the Firebase Crashlytics SDK.
implementation 'com.google.firebase:firebase-crashlytics:17.0.0'
// Recommended: Add the Google Analytics SDK.
implementation 'com.google.firebase:firebase-analytics:17.4.1'
}
Update your code
Crashlytics.log is now an instance method
From Fabric: Crashlytics.log("my message");
To Firebase Crashlytics SDK:
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
// To log a message to a crash report, use the following syntax:
crashlytics.log("E/TAG: my message");
The crash method is removed
From Fabric: Crashlytics.getInstance().crash().
To Firebase Crashlytics SDK:
throw RuntimeException("Test Crash")
Now, FirebaseCrashlytics starts up automatically using a
ContentProvider defined in the new Firebase Crashlytics SDK. Remove
calls to Fabric.with() if they exist. If you're already using Firebase
Crashlytics, your app may already be using automatic startup and may
not contain a call to Fabric.with().
GL
I came across this issue in the new Firebase SDK upgrade to 17.0.0+ version.
The issue was caused when we use multiple flavors. In case you are using a separate flavor - debug and have it linked to firebase as well, instead of adding the google-services.json file to the app root, we have to add the flavor specific json file to the appropriate folder for the flavor - app -> src -> (flavor folder).
This will ensure that the generated code has the correct client id for the flavor.
This is a silly mistake but there are chances for people to miss it.
At First you have to enable the Crashlytics in the Crashlytics tab in your project in the console (before or after adding all the dependencies of crashlytics) or follow these steps present in this
link:
https://firebase.google.com/docs/crashlytics/get-started?authuser=0&platform=android
After checking internet connection, I solved this issue by activate Crashlytics for my app in the Firebase console (then, relaunch app and all should work fine)
I posting this answer for those who want it to get it working without unlinking their app from Firebase Crashlytics.
To Achieve this they have to do following,
Add fabric API key back in AndroidManifest as metadata.
<meta-data
android:name="io.fabric.ApiKey"
android:value="fabric_api_key"
/>
Initialize Fabric.
Fabric.with(this, new Crashlytics());
After doing these two steps Crashlytics starts working again without unlinking your app.

Firebase assistant not showing in Studio 2.2.3

I am trying to connect Firebase with my app and I was following all the steps in this link.
I have the latest Google Repo and android studio 2.2.3, but when I open the Tools drop down menu there is no Firebase option.
Any idea of what I am missing?
In the Android Studio, go to File -> Settings, click on Plugins and then enable all Firebase plugins.
This image below should help.
First you need to sign in to your Google account by clicking on the icon in the upper right corner of android studio. Then the Firebase item will appear in the Tools menu.
In android studio 3.6.1 I used the long way but it worked as shown below:
Log in to Android Studio 3.6.1 from the to right user icon
Log in to firebase console with the same account address
On the firebase console start a new project
In the center of the project overview page, click the Android icon (plat_android) to launch the setup workflow.
5.Enter your app's package name in the Android package name field
Add the Firebase Android configuration file to your app by:
Click Download google-services.json to obtain your Firebase Android config file (google-services.json).
Move your config file into the module (app-level) directory of your app.
To enable Firebase products in your app, add the google-services plugin to your Gradle files.
In your root-level (project-level) Gradle file (build.gradle), add rules to include the Google Services Gradle plugin. Check that you have Google's Maven repository, as well.
11
`buildscript {
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
// ...
// Add the following line:
classpath 'com.google.gms:google-services:4.3.3' // Google Services plugin
}
}
allprojects {
// ...
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
// ...
}
}`
11
.In your module (app-level) Gradle file (usually app/build.gradle), apply the Google Services Gradle plugin:
apply plugin: 'com.android.application'
// Add the following line:
apply plugin: 'com.google.gms.google-services' // Google Services plugin
android {
// ...
}
Add Firebase SDKs to your app
To your module (app-level) Gradle file (usually app/build.gradle), add the dependencies for the Firebase products that you want to use in your app.
dependencies {
// ...
// Add the Firebase SDK for Google Analytics
implementation 'com.google.firebase:firebase-analytics:17.3.0'
// Add the dependencies for any other Firebase products you want to use in your app
// For example, to also use Firebase Authentication
implementation 'com.google.firebase:firebase-auth:19.3.0'
// Getting a "Could not find" error? Make sure that you've added
// Google's Maven repository to your root-level build.gradle file
}
Sync your app to ensure that all dependencies have the necessary versions.
If you added Analytics, run your app to send verification to Firebase that you've successfully integrated Firebase. Otherwise, you can skip the verification step.
Your device logs will display the Firebase verification that initialization is complete. If you ran your app on an emulator that has network access, the Firebase console notifies you that your app connection is complete.
In Android Studio 3 , Go To Tools - > Android - > SDK Manager - > under that plugins in which search Firebase and there are three plugins click all then your android studio restart and can see Firebase Assistant there under tools ... Enjoy
Android Studio 3.4.1, Go to Tools -> Firebase

Android Studio - Cannot resolve symbol 'firebase'

I'm currently upgrading an app to the new Firebase version. I followed the guide, included classpath 'com.google.gms:google-services:3.0.0' in the dependencies of my project build.gradle as well as compile 'com.google.firebase:firebase-core:9.0.1' among others in the dependencies of my module build.gradle and also apply plugin: 'com.google.gms.google-services' at the end of that file.
I get a "cannot resolve symbol 'firebase'" in my imports i.e. import com.google.firebase.database.DatabaseReference;. Those are not errors that appear when building, so this seems to be working, but they are visible in the code editor of Android Studio.
The imports worked just fine a couple of days ago (except for FirebaseAuth, which was under maintenance). I did not change anything about the code since then (except trying to upgrade to 9.0.2, which lead to the same result). The only thing I did was update some components of the Android SDK, but I can't remember which. The Android SDK as well as Google Repository and Google Play Services are of the newest version. Rebuilding, cleaning and invalidate caches / restart had no effect.
Any ideas how to fix this?
You need to add this dependency in your build.gradle(app)
compile 'com.firebase:firebase-client-android:2.5.0'
Now with New Android Studio ,Its so easy to add Firebase to your Project.
Below are Simple Steps-
1. On Android Studio’s Tools menu, you’ll see an entry that reads Firebase.
2. Select this, and a Firebase Assistant pane will open to the side of your code editor:
3. On this pane, click the arrow beside ‘Authentication’, and you’ll see a step through for ‘Email and Password Authentication’.
4. Click the ‘Connect to Firebase’ button.
Your browser will open with a ‘Request for Permissions’ dialog:
5.Click ‘Allow’, and then after a ‘Success!’ screen, you’ll be given a dialog with which to connect to Firebase.
6.You will see Connected .Its Done !
For more on Firebase refer here.
You can open and use the Assistant window in Android Studio by following these steps:
Click Tools > Firebase to open the Assistant window. And it will guide you for sync firebase and your project.
Make sure you fulfill the following prerequisites before adding firebase to your project.
For working with Firebase you should install Android Studio 1.5 or higher.
Download the latest Google Play services SDK from through Android SDK Manager.
The device should be running Android 2.3 (Gingerbread) or newer, and Google Play services 9.2.0 or newer.
I find out all this after hours of struggle, so thought of sharing with others.
Source: Adding Firebase to your Android App
Invalidating cache didn't work for me. But deleting .idea/libraries worked like magic.
More info here: https://stackoverflow.com/a/50129167/971972
Add following in your gradle file under dependencies:
compile 'com.firebase:firebase-client-android:2.5.2'
If you are getting a build error complaining about duplicate files you can choose to exclude those files by adding the packagingOptions directive to your build.gradle file:
android {
...
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
To use the Firebase Messaging service you need to add the following dependencies to your app's build.gradle file:
compile 'com.google.firebase:firebase-messaging:9.4.0'
I had the same problem but thanks to this answer:
https://stackoverflow.com/a/39353961/4836759
In the new SDK, it's no longer necessary to call Firebase.setAndroidContext() so you can remove it from your code.
In the new SDK, Firebase references are replaced by DatabaseReference and you use the FirebaseDatabase class to get an initial reference to your database. So you can get the database reference in your code as follows:
BEFORE
Firebase rootRef = new Firebase("https://.firebaseio.com/");
AFTER
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
Note that your Database URL is automatically determined from the google-services.json file you downloaded, so you don't need to specify it. If you want to specify it though, you still can (which might be convenient for migration purposes):
BEFORE
Firebase ref = new Firebase("https://.firebaseio.com/path/to/data");
AFTER
DatabaseReference ref = FirebaseDatabase.getInstance()
.getReferenceFromUrl("https://.firebaseio.com/path/to/data");
22
After adding it in from the built in Firebase tool and also following the following a tutorial, the imports did not work on one of my classes so all you have to do is sync the gradle files
Tutorial I've used:
https://www.androidtutorialpoint.com/firebase/firebase-cloud-messaging-tutorial/
Tools/Android/Sync Project with Gradle Files.
Works 100% now
You need the Firebase client library. Add this to your app gradle:
dependencies {
// Firebase
implementation 'com.firebase:firebase-client-android:2.5.2'
Replace 2.5.2 with the latest version (there is probably a new one out there since I posted this answer).
dependencies should be used in the latest gradle version (not compile).

Fail to retrieve settings from crashlytics [duplicate]

I am trying out the new Firebase/Crashlytics setup and seem to run into a weird issue.
I have one Android code base with multiple product flavors and each flavor is a separate individual app.
all of these apps are registered in Fabric (from the past)
all of these apps are added in Firebase
All linking between the two seems ok (from Fabric side as well as from Firebase side, it says that it is all linked up)
I removed the Fabric API key from the manifest file and added the appropriate plugins/dependencies etc. to both gradle files
I try to send a test crash report as per Firebase instructions.
I receive it perfectly fine on one of the product flavors, so I assume all works well.
However,
the rest of the product flavors do not send the crash report and I get this error in log:
E/Fabric: Failed to retrieve settings from https://settings.crashlytics.com/spi/v2/platforms/android/apps/package name/settings
Ok, I think I solved the problem, but the solution does not seem to be the way it should work (at least I do not think).
Go to Firebase Console > Project Settings > Account Linking > Fabric > Select the app and Unlink it
Confim in Fabric > App > Firebase - that it is unlinked
Go to Firebase > Project > Crashlytics (select the app you want) and you should now get a dialog to link your app again
Choose to link as a New Crashlytics (not existing one) and follow the directions
After that all should work fine
So basically, from Fabric>Firebase screen - there is no link visible and from Firebase>Account Linking>Fabric screen - there is also no linking visible. So no linking, but your crashes will be visible in Firebase.
This takes me a lot of time than I figured out how to migrate correctly. Actually you have two ways how to do it:
Perform clean migration without keeping crash history from Fabric Crashlytics
This way is described in Firebase Crashlytics developer guide. You have to here remove com.crashlytics.ApiKey meta-data from app manifest file.
With this way you must not link Fabric with Firebase otherwise crashes will not shown in Firebase nor Fabric console.
Link Fabric with Firebase and keep the crash history
This way is probably nowhere documented. Crucial is here to keep com.crashlytics.ApiKey meta-data in your manifest. Then you need to link Fabric Crashlytics with Firebase. You can also enable forwarding Events (formerly Answers) to Firebase Analytics. Both actions are presented in Fabric console, look for Firebase in a side menu.
All new crash reports show up in both Fabric console and Firebase console. Also this linking arrange a copying all Fabric crash report history to Firebase.
I think firebase-core artifact is not necessary here, but I added it. I'm also using Fabric Events, so with firebase-core additional app usage events was appeared in Firebase Analytics.
I had the same issue and it took me a lot of time to figure out.
I solved my problem by going to FireBase Console > [my project] > Crashlytics. In the dropdown you need to select your app. After that a wizard with three steps will show up.
Click whatever option suits you, I chose the first because it's a new app. After that the second step shows up.
Now here comes the important part. Make sure you click the link to go to the documentation! A new browser tab will open up. If you already finished the project setup like me, you can close it. After that you will automatically go to the 3rd option. Most of the time I never clicked the link because I had already completed the installation. And once I did I never noticed that the 3rd option was available because I'm at the other tab. As a result I never got to see the 3rd option.
At this point you should open your app and it will automatically connect to Firebase without any problem.
Edit: After I tried to add some other build variants I noticed that I was still getting some errors while retrieving the settings. It took me a lot of time to figure out how to solve it. The best thing I could come up with is:
switch to build variant
perform an assemble[YOUR_BUILD_VARIANT] on the gradle tab.
build > rebuild project
delete old app from device if present.
install app and open it.
Sometimes this also didn't work and I tried the same steps again one or two times and suddenly it started working...
It also helped me to enable additional debug logging for fabric and crashlytics.
adb shell setprop log.tag.Fabric DEBUG
adb shell setprop log.tag.CrashlyticsCore DEBUG
If there's network connectivity (like in Airplane mode), you will get this error even if everything is setup correctly.
You will also get:
E/Fabric﹕ Failed to retrieve settings from https://settings.crashlytics.com/spi/v2/platforms/android/apps/com.xyz/settings
W/Fabric﹕ Received null settings, skipping initialization!
To prevent Crashlytics from further crashing when logging, I do this:
boolean fabricInitialized = Fabric.isInitialized();
if (fabricInitialized) {
Crashlytics.log(someString);
}
Go to the settings of the project and add SHA-1 key for your android app.
After that redownload google-service.json to your sources.
This causes disappearing of this error
E/Fabric: Failed to retrieve settings from https://settings.crashlytics.com/spi/v2/platforms/android/apps/package name/settings
And after quite a huge delay you'll see crashes in Firebase Console.
By the way this doesn't help me with apps that were registered under one Google account, and after that moved to another account. Wiating for a response of Firebase team about this issue.
You probably forgot to add:
<meta-data
android:name="io.fabric.ApiKey"
android:value="h4132h4k324hjh4l4324h24hk21h4kj2h4" />
To your Manifest file. At least in my case, that was the reason.
In my case, the location of meta-data:io.fabric.ApiKey was wrong.
app/src/main/AndroidManifest.xml
before
<application
...>
<activity
...>
<meta-data
android:name="io.fabric.ApiKey"
android:value="xxxxxx" />
</activity>
</application>
after
<application
...>
<activity
...>
</activity>
<meta-data
android:name="io.fabric.ApiKey"
android:value="xxxxxx" />
</application>
I hope this will be of some help.
I'm finding out that I had to unregister and re-register my existing apps with Firebase after converting over to FirebaseCrashlytics.
Make sure you get your app to the following point before running it for it's initial FirebaseCrashlytics registration (console waits for initial registration), otherwise it won't register:
enter image description here
None of this is obvious!
Upgrade to the Firebase Crashlytics SDK Android & iOS
You can now set up Crashlytics in your app by using the new official Firebase Crashlytics SDK, which offers improved APIs that are more consistent with other Firebase products and more intuitive to use. This guide describes how to upgrade to the new SDK from the Fabric Crashlytics SDK. It describes the changes that come with the new APIs, the reason for the changes, and how to update your code, if required.
Android
Precondition: Migrate your app to AndroidX
1. Add a Firebase configuration file
Open your Project Settings.
Click Download google-services.json to obtain your Firebase Android config file.
Move your config file into the module (app-level) directory of your app.
2. Switch your dependencies
(project-level)/build.gradle
Deprecated From:
buildscript {
// ...
repositories {
// ...
// Remove Fabric's Maven repository.
maven { url 'https://maven.fabric.io/public' }
// Add Google's Maven repository (if it's not there already).
google()
}
dependencies {
// ..
// Add the Google Services Gradle plugin (if it's not there already).
classpath 'com.google.gms:google-services:4.3.3'
// Remove the Fabric Gradle plugin.
classpath 'io.fabric.tools:gradle:1.31.2'
}
}
To:
buildscript {
// ...
repositories {
// ...
// Add Google's Maven repository (if it's not there already).
google()
}
dependencies {
// ..
// Add the Google Services Gradle plugin (if it's not there already).
classpath 'com.google.gms:google-services:4.3.3'
// Add the Firebase Crashlytics Gradle plugin.
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.0'
}
}
(app-level)/build.gradle
Finally, add the Firebase Crashlytics SDK. In your app-level build.gradle, replace the legacy Fabric Crashlytics SDK with the new Firebase Crashlytics SDK. For an optimal experience with Firebase Crashlytics, we recommend also adding the Firebase SDK for Google Analytics to your app (make sure to add Version 17.2.3 or later in order to get real time crash-free users and breadcrumbs).
Deprecated From:
apply plugin: 'com.android.application'
// Apply the Google Services plugin (if it's not there already).
apply plugin: 'com.google.gms.google-services'
// Remove the Fabric plugin.
apply plugin: 'io.fabric'
dependencies {
// Remove the Fabric Crashlytics SDK.
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
// Recommended: Add the Google Analytics SDK.
implementation 'com.google.firebase:firebase-analytics:17.4.1'
}
To:
apply plugin: 'com.android.application'
// Apply the Google Services plugin (if it's not there already).
apply plugin: 'com.google.gms.google-services'
// Add the Firebase Crashlytics plugin.
apply plugin: 'com.google.firebase.crashlytics'
dependencies {
// Add the Firebase Crashlytics SDK.
implementation 'com.google.firebase:firebase-crashlytics:17.0.0'
// Recommended: Add the Google Analytics SDK.
implementation 'com.google.firebase:firebase-analytics:17.4.1'
}
Update your code
Crashlytics.log is now an instance method
From Fabric: Crashlytics.log("my message");
To Firebase Crashlytics SDK:
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
// To log a message to a crash report, use the following syntax:
crashlytics.log("E/TAG: my message");
The crash method is removed
From Fabric: Crashlytics.getInstance().crash().
To Firebase Crashlytics SDK:
throw RuntimeException("Test Crash")
Now, FirebaseCrashlytics starts up automatically using a
ContentProvider defined in the new Firebase Crashlytics SDK. Remove
calls to Fabric.with() if they exist. If you're already using Firebase
Crashlytics, your app may already be using automatic startup and may
not contain a call to Fabric.with().
GL
I came across this issue in the new Firebase SDK upgrade to 17.0.0+ version.
The issue was caused when we use multiple flavors. In case you are using a separate flavor - debug and have it linked to firebase as well, instead of adding the google-services.json file to the app root, we have to add the flavor specific json file to the appropriate folder for the flavor - app -> src -> (flavor folder).
This will ensure that the generated code has the correct client id for the flavor.
This is a silly mistake but there are chances for people to miss it.
At First you have to enable the Crashlytics in the Crashlytics tab in your project in the console (before or after adding all the dependencies of crashlytics) or follow these steps present in this
link:
https://firebase.google.com/docs/crashlytics/get-started?authuser=0&platform=android
After checking internet connection, I solved this issue by activate Crashlytics for my app in the Firebase console (then, relaunch app and all should work fine)
I posting this answer for those who want it to get it working without unlinking their app from Firebase Crashlytics.
To Achieve this they have to do following,
Add fabric API key back in AndroidManifest as metadata.
<meta-data
android:name="io.fabric.ApiKey"
android:value="fabric_api_key"
/>
Initialize Fabric.
Fabric.with(this, new Crashlytics());
After doing these two steps Crashlytics starts working again without unlinking your app.

Categories

Resources