Execution failed for task ':app:uploadCrashlyticsMappingFileRelease'.Host name must not be empty
Asked Answered
T

2

7

When trying to create a release signed apk, Build fails at task
app:uploadCrashlyticsMappingFileRelease'.Host name must not be empty.

I have enabled obfuscation .

buildTypes {

        release {

            minifyEnabled true // Enables code shrinking, obfuscation, and optimization

            shrinkResources true // Enables resource shrinking, which is performed by the Android Gradle plugin


            firebaseCrashlytics {

                mappingFileUploadEnabled true
            }

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

Also,using

    apply plugin: 'com.android.application'
    
       apply plugin: 'com.google.gms.google-services'
    
       // Apply the Crashlytics Gradle plugin
    
       apply plugin: 'com.google.firebase.crashlytics'
    
        implementation 'com.google.firebase:firebase-auth:20.0.1'
        implementation 'com.google.firebase:firebase-firestore:22.0.1'
        implementation 'com.google.firebase:firebase-core:18.0.0'
    
        //the Firebase SDK for Google Analytics.
        implementation 'com.google.firebase:firebase-analytics:18.0.0'
    
        //the Firebase Crashlytics SDK.
        implementation 'com.google.firebase:firebase-crashlytics:17.3.0'

and,

        classpath 'com.google.gms:google-services:4.3.4'  // Google Services plugin

        // Add the Crashlytics Gradle plugin.
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'

Anyone facing the same issue? I tried clearing gradle cache and removing crashlytics dependencies as i read that it will be automatically handled by Android Studio,but crashes are not recorded then.

Iam using Android Studio 4.1.1(upgraded from previous version)

Build #AI-201.8743.12.41.6953283, built on November 5, 2020 Runtime version: 1.8.0_242-release-1644-b3-6222593 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Linux 5.4.0-58-generic GC: ParNew, ConcurrentMarkSweep Memory: 1246M Cores: 4 Registry: ide.new.welcome.screen.force=true, external.system.auto.import.disabled=true Non-Bundled Plugins: com.android.tool.sizereduction.plugin Current Desktop: ubuntu:GNOME.

Thereof answered 29/12, 2020 at 7:6 Comment(0)
B
9

There are Two possible fixes here...

First one which is a less likely solution is to rearrange the order of plugins in your build.gradle project file and bring apply plugin: 'com.google.firebase.crashlytics' right under the google-services top plugin call in your project's build.gradle file so that you have this arrangement on top BEFORE you call other libraries or apply other plugins needed So like this

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

enter image description here

- The second solution which is likely and started as at android studio 4.0 up is to edit your global gradle.propeties file installation on your computer...

Here is the clearer fix with pictures below... (Cos Some may think the "gradle.properties" file being talked about here is what is in the AS project instead of the global one.

Delete the following lines from the "gradle.propeties" file on your PC gradle installation location

systemProp.http.proxyHost= systemProp.https.proxyHost= systemProp.https.proxyPort=80 systemProp.http.proxyPort=80

as seen in n my picture below here is a typical file location of this gradle.propeties file enter image description here

enter image description here

Now click rebuild in your project and VIOLA... Problem solved

Boa answered 3/12, 2021 at 7:56 Comment(2)
works fine, solves the issue. Verified in 2023Leanora
Also, another solution is to delete the following lines from global gradle.properties file. "systemProp.http.proxyHost= systemProp.http.proxyPort=80 systemProp.https.proxyHost= systemProp.https.proxyPort=80" These can be found on mac in /Users/username/.gradle/gradle.properties It's a hidden folder. And when you delete this http proxy settings, the internet connection from gradle works properly. Thus no host name errorDeadman
S
1

To enable Crashlytics mapping file upload for specific product flavors:

import com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension

android {
 buildTypes {
   getByName("debug") {
   minifyEnabled = true

   configure<CrashlyticsExtension> {
    mappingFileUploadEnabled = false
   }

 }
}


 
Semblable answered 20/9, 2023 at 17:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.