# DexGuard：混淆失败：无法读取映射文件：/path/to/mapping.txt

- **ID:** `android/dexguard-obfuscation-missing-mapping`
- **领域:** android
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 82%

## 根因

DexGuard 期望之前的 mapping.txt 文件用于增量混淆，但文件缺失或路径不正确。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| DexGuard 9.3.0 | active | — | — |
| DexGuard 10.0.0 | active | — | — |
| AGP 8.2.0 | active | — | — |
| Gradle 8.5 | active | — | — |

## 解决方案

1. ```
   Add `-applymapping /path/to/valid/mapping.txt` in DexGuard config with the correct path from a previous successful build, or remove the line if incremental obfuscation is not needed.
   ```
2. ```
   Run a full clean build: `./gradlew clean assembleRelease` without incremental mapping to generate a new mapping.txt file.
   ```

## 无效尝试

- **** — Setting `-dontobfuscate` in DexGuard config disables obfuscation entirely, which defeats the purpose of using DexGuard for security. (50% 失败率)
- **** — Copying a mapping.txt from a different build variant or version may cause class name conflicts and runtime crashes. (90% 失败率)
- **** — Clearing the entire build cache with `./gradlew clean` deletes all intermediate files, including mapping.txt, worsening the issue. (70% 失败率)
