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

6
尝试创建已签名的apk时,构建失败在任务:app:uploadCrashlyticsMappingFileRelease'。主机名不能为空。 我已启用混淆。
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'
        }
    }

另外,使用

    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'
并且,
        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'

有人遇到相同的问题吗? 我尝试清除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:由JetBrains s.r.o提供的OpenJDK 64位 Server VM 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 非捆绑插件: com.android.tool.sizereduction.plugin 当前桌面:ubuntu:GNOME。

2个回答

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

enter image description here

-第二种解决方案是在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文件的典型文件位置

enter image description here

enter image description here

现在在您的项目中点击重建,问题解决了


运行良好,解决了问题。在2023年进行了验证。 - oyeraghib
另外,另一种解决方案是从全局gradle.properties文件中删除以下行。 "systemProp.http.proxyHost= systemProp.http.proxyPort=80 systemProp.https.proxyHost= systemProp.https.proxyPort=80"这些可以在Mac上的/Users/username/.gradle/gradle.properties中找到。 这是一个隐藏的文件夹。当您删除这些HTTP代理设置时,Gradle的互联网连接将正常工作。因此,不会出现主机名错误。 - undefined

0
为了在特定的产品风味中启用Crashlytics映射文件上传:
import com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension

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

   configure<CrashlyticsExtension> {
    mappingFileUploadEnabled = false
   }

 }
}


 

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,