FirebaseCrashlytics: Settings request failed

17.9k Views Asked by At

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
  }
3

There are 3 best solutions below

4
SarangD On BEST ANSWER

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.

0
Sattar On

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.

2
fish07 On

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>