任务“:app:uploadCrashlyticsMappingFileRelease”执行失败。主机名不能为空

ddk*_*ddk 6 obfuscation android proguard crashlytics android-studio

尝试创建发布签名的 apk 时,构建在任务中失败
app:uploadCrashlyticsMappingFileRelease'.Host name must not be empty.

我已经启用了混淆功能

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'
        }
    }
Run Code Online (Sandbox Code Playgroud)

另外,使用

    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'
Run Code Online (Sandbox Code Playgroud)

和,

        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'
Run Code Online (Sandbox Code Playgroud)

有人面临同样的问题吗?我尝试清除 gradle 缓存并删除 crashlytics 依赖项,因为我读到它将由 Android Studio 自动处理,但当时不会记录崩溃。

我使用Android Studio 4.1.1(从以前的版本升级)

构建 #AI-201.8743.12.41.6953283,构建于 2020 年 11 月 5 日 运行时版本:1.8.0_242-release-1644-b3-6222593 amd64 VM:OpenJDK 64 位服务器 VM by JetBrains sro Linux 5.4.0-58-generic GC:ParNew、ConcurrentMarkSweep 内存:1246M 核心:4 注册表:ide.new.welcome.screen.force=true、external.system.auto.import.disabled=true 非捆绑插件:com.android.tool.sizereduction.plugin当前桌面:ubuntu:GNOME。

Sam*_*oom 6

这里有两个可能的修复...

第一个不太可能的解决方案是重新排列 build.gradle 项目文件中插件的顺序,并将其放在 apply plugin: 'com.google.firebase.crashlytics'项目的 build.gradle 文件中的 google-services 顶级插件调用下方,以便在您之前将这种安排放在顶部调用其他库或应用所需的其他插件所以像这样

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

- 第二个解决方案可能是从 android studio 4.0 开始的,是编辑计算机上的全局 gradle.propeties 文件安装...

下面是更清晰的修复图片...(因为有些人可能认为这里讨论的gradle.properties ”文件是 AS 项目中的文件,而不是全局文件。

从PC gradle 安装位置的“gradle.propeties”文件中删除以下行

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

正如我下面的图片所示,这是这个gradle.propeties文件 的典型文件位置在此输入图像描述

在此输入图像描述

现在在您的项目和 VIOLA 中单击“重建”...问题已解决