# DexGuard：找不到映射文件：/path/to/mapping.txt。混淆可能失败。

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

## 根因

DexGuard 需要映射文件进行增量混淆，但由于清理构建或输出路径配置错误，该文件缺失。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| DexGuard 9.0 | active | — | — |
| DexGuard 10.0 | active | — | — |
| Android Gradle Plugin 7.4 | active | — | — |
| Android Gradle Plugin 8.0 | active | — | — |

## 解决方案

1. ```
   临时添加 '-dontobfuscate' 让 DexGuard 生成新映射文件，然后重新启用混淆并指定正确路径。
   ```
2. ```
   在 DexGuard 配置中设置映射文件输出路径：'-printmapping /path/to/mapping.txt' 并确保目录存在。
   ```
3. ```
   执行干净构建（./gradlew clean）并重新构建；如果输出目录可写，DexGuard 将创建新的映射文件。
   ```

## 无效尝试

- **** — DexGuard expects a mapping file for consistent obfuscation; without it, obfuscation may fail or produce inconsistent results. (80% 失败率)
- **** — This defeats the purpose of using DexGuard and may leave the app unprotected. (90% 失败率)
