Bugsnag:上传源映射时出错?

Bugsnag: Error uploading source mappings?

我正在尝试将源映射上传到 Bugsnag,这样我就可以在发生错误时查看完整的堆栈跟踪,而不是捆绑文件的堆栈跟踪。我按照 this 页面上的说明进行操作,但在尝试构建 APK 时出现此错误:

> Task :app:uploadBugsnagReleaseMapping
Mapping file not found: null

我查看了我的 android\app\build.gradle 文件,发现 minifiedEnabled 属性 设置为 false。我改成true然后错误改成:

Mapping file not found: C:\Development\React Native Practise\bugsnag_practise\android\app\build\outputs\mapping\release\mapping.txt

我想我需要手动添加文件,所以我在该目录中添加了一个具有该名称的空文本文件并得到了这个:

Attempting upload of mapping file to Bugsnag
Bugsnag upload failed with code 422: Received empty file
Retrying Bugsnag upload (1/5) ...
Attempting upload of mapping file to Bugsnag
Bugsnag upload failed with code 422: Received empty file
Retrying Bugsnag upload (2/5) ...
Attempting upload of mapping file to Bugsnag
Bugsnag upload failed with code 422: Received empty file
Retrying Bugsnag upload (3/5) ...
Attempting upload of mapping file to Bugsnag
Bugsnag upload failed with code 422: Received empty file
Retrying Bugsnag upload (4/5) ...
Attempting upload of mapping file to Bugsnag
Bugsnag upload failed with code 422: Received empty file
Retrying Bugsnag upload (5/5) ...
Attempting upload of mapping file to Bugsnag
Bugsnag upload failed with code 422: Received empty file

如果有帮助,这是我在 android\app\build.gradle:

中的 bugsnag 配置
bugsnag {
    autoUpload true
    ndk false
    autoReportBuilds true
    autoProguardConfig true
    overwrite true
    retryCount 5
}

和我的 buildTypes 配置在同一个文件中:

buildTypes {
    release {
        signingConfig signingConfigs.release
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}

是否缺少将填充此文件的配置选项?

您需要在 app/proguard-rules.pro

中禁用混淆
# Disabling obfuscation is useful if you collect stack traces from production crashes
# (unless you are using a system that supports de-obfuscate the stack traces).
# Disable to generate mapping.txt Enable for production apk
-dontobfuscate <- Comment this line

然后重试