# 错误：未向注解处理器提供架构导出目录，因此无法导出架构。您可以提供 `room.schemaLocation` 注解处理器参数，或将 exportSchema 设置为 false。

- **ID:** `android/room-schema-export-missing`
- **领域:** android
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

Room 数据库注解处理器需要架构导出目录以进行迁移验证，但未在 build.gradle 中配置，或者 exportSchema 设置为 true 但未提供路径。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Room 2.5 - 2.6 | active | — | — |
| Android Gradle Plugin 7.4 - 8.2 | active | — | — |

## 解决方案

1. ```
   Add the following to build.gradle (app-level) for kapt: 'kapt { arguments { arg("room.schemaLocation", "$projectDir/schemas") } }' or for annotationProcessor: 'defaultConfig { javaCompileOptions { annotationProcessorOptions { arguments = ["room.schemaLocation": "$projectDir/schemas"] } } }'
   ```
2. ```
   Set exportSchema = false in the @Database annotation if migration validation is not needed: '@Database(entities = [User::class], version = 1, exportSchema = false)'
   ```

## 无效尝试

- **** — If exportSchema is false, the schema is not exported, but the error may still occur if the processor expects the argument; the build.gradle configuration is still needed. (50% 失败率)
- **** — The path must be a valid project-relative directory; a wrong path causes the processor to fail silently or create the schema in an unexpected location. (50% 失败率)
