15

I almost finished building my android app, but I want to add FirebaseCrashlytics. I always add this and I never had a problem installing it. But now its diffrent. I get the following error:

2021-05-24 20:41:42.807 11296-11333/com.example.depeuleschil E/FirebaseCrashlytics: Settings request failed.
java.io.FileNotFoundException: https://firebase-settings.crashlytics.com/spi/v2/platforms/android/gmp/1:966637647957:android:9f830999a842bf19b5fcdc/settings?instance=864af142db1afeaf05a53d2c5a0bee2a10c2f546&build_version=1&display_version=1.0&source=1
    at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:255)
    at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:211)
    at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:30)
    at com.google.firebase.crashlytics.internal.network.HttpGetRequest.execute(HttpGetRequest.java:80)
    at com.google.firebase.crashlytics.internal.settings.network.DefaultSettingsSpiCall.invoke(DefaultSettingsSpiCall.java:113)
    at com.google.firebase.crashlytics.internal.settings.SettingsController$1.then(SettingsController.java:199)
    at com.google.firebase.crashlytics.internal.settings.SettingsController$1.then(SettingsController.java:192)
    at com.google.android.gms.tasks.zzp.run(Unknown Source:2)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at com.google.firebase.crashlytics.internal.common.ExecutorUtils$1$1.onRun(ExecutorUtils.java:64)
    at com.google.firebase.crashlytics.internal.common.BackgroundPriorityRunnable.run(BackgroundPriorityRunnable.java:27)
    at java.lang.Thread.run(Thread.java:923)

I have spent 2 hours on google already and on Stackoverflow there are some people that encounter the same sort of problem. But the problem is always slightly different and I have literally tried every suggesting that I could find on Stackoverflow, but nothing works.

This is the documentation I use: https://firebase.google.com/docs/crashlytics/get-started?platform=android

I have deleted and cleared the firebase app online and tried to reinstall (3 times) but nothing works. I hope someone can help me with this problem.

This is my gradle file (app level)

plugins {
id 'com.example.test'
id 'kotlin-android'
id 'kotlin-kapt'
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"

defaultConfig {
    applicationId "com.example.test"
    minSdkVersion 16
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"
    //for support vector images in an imageview
    vectorDrawables.useSupportLibrary = true


    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
    jvmTarget = '1.8'
}
buildFeatures {
    viewBinding true
}
}

dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.recyclerview:recyclerview:1.2.0'
// cardView library
implementation 'androidx.cardview:cardview:1.0.0'
// Viewpager2
implementation 'androidx.viewpager2:viewpager2:1.0.0'
//tablayout
implementation 'com.google.android.material:material:1.4.0-beta01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.synnapps:carouselview:0.1.5'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

// firebase
implementation platform('com.google.firebase:firebase-bom:28.0.1')
implementation 'com.google.firebase:firebase-crashlytics-ktx'
implementation 'com.google.firebase:firebase-analytics-ktx'
 }

and this is my build.gradle (package level)

buildscript {
ext.kotlin_version = "1.4.32"
repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:4.2.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    classpath 'com.google.gms:google-services:4.3.8'
    classpath 'com.google.firebase:firebase-crashlytics-gradle:2.6.1'
}
}
allprojects {
    repositories {
         google()
         jcenter()
     }
  }

 task clean(type: Delete) {
     delete rootProject.buildDir
  }
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
chrispsv
  • 503
  • 1
  • 3
  • 21
  • Does this answer your question? [E/FirebaseCrashlytics: Failed to retrieve settings from https://firebase-settings.crashlytics.com/spi/v2/platforms/android/gmp/XXXX/settings](https://stackoverflow.com/questions/62196832/e-firebasecrashlytics-failed-to-retrieve-settings-from-https-firebase-setting) – Martin Zeitler May 24 '21 at 20:06
  • No I have literally tried all the solutions in that topic but nothing works. – chrispsv May 24 '21 at 20:10
  • This doesn't change the fact that your question is a duplicate and it doesn't provide the least information to reproduce the issue. As abstract as it is, this also lacks debug information. Posting some error message and complaining doesn't count as a question. – Martin Zeitler May 24 '21 at 20:12
  • I'm sorry, I just added the files that should matter (I totally forgot in al my frustration). – chrispsv May 24 '21 at 20:31
  • 4
    In the URL it shows this: 1:966637647957:android:9f830999a842bf19b5fcdc this is your app Id. Make sure 1) this app ID exists in your project. 2) if it doesn't, or the app id is now different, that would mean you are using an older google-services.json file. In that case, just try downloading a new one. And, make sure Crashlytics is enabled in the app. – Gerardo May 25 '21 at 04:55
  • Thank you very much! replacing the google-services.json file fixed my problem. (I already did that yesterday once and that didn't work but this morning it did so thank you very much!) :) – chrispsv May 25 '21 at 09:31

3 Answers3

15

I faced a similar error. After looking at several potential solutions and even workarounds, I inspected the URL from which the settings were being attempted to be fetched. I found that my App Id was set to an old id.

Use the latest google-services.json file from your Firebase console (add it to your project).

P.S.: Do check your other related Google/Firebase tools and services after updating google-services.json in your app. This little issue was also blocking my Firebase events.

P.P.S.: +1 to @Gerardo's answer above.

SarangD
  • 198
  • 1
  • 9
  • 2
    Do you keep getting the error even after using the latest `google-services.json`? – SarangD Jul 13 '21 at 08:12
  • 8
    So, for me the error was I did not enabled crashlytics in my console. My bad. But even then it didnt work (just empty page in firebase console), until I actually forced my app to crash at least once. And only after that it started showing crashes in console... – qkx Jul 13 '21 at 09:02
  • 3
    Yes, you'll find that in the docs. Your app needs to crash once for initialization. That's what the Crashlytics docs Get Started function helps to do. Hope your issue is now solved. – SarangD Jul 13 '21 at 09:17
  • 1
    I was using two package names to enable installing two flavors on the same phone. That meant I had to enable Crashlytics to the other package name as well in the Firebase console. – CaptainNemo Nov 13 '21 at 07:40
1

I faced the same issue and checked all the ids of the app and everything was the same as firebase but when I went to the crashlytics tab on firebase I found that I didn't enable it so it worked after enabling it.

Sattar
  • 2,453
  • 2
  • 33
  • 47
-2

In android 9.0 and above cleartextTrafficPermitted is set to false by default

which blocks any http request sent from your app

to fix this issue you must allow domain firebase-settings.crashlytics.com

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="false">
        <trust-anchors>
            <certificates src="system" />
        </trust-anchors>
    </base-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">firebase-settings.crashlytics.com</domain>
    </domain-config>
</network-security-config>
fish07
  • 1
  • 1
  • 2