# error: Cannot find getter for field. Room cannot find the getter for field 'userId' in class 'User'.

- **ID:** `android/room-cannot-find-getter`
- **Domain:** android
- **Category:** build_error
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

Room requires getter methods for each field in an entity, but the field is private and no public getter exists.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Room 2.4.0+ | active | — | — |
| Android Studio 2021.3+ | active | — | — |

## Workarounds

1. **Add a public getter method for the field: public int getUserId() { return userId; }** (95% success)
   ```
   Add a public getter method for the field: public int getUserId() { return userId; }
   ```
2. **Use Kotlin data class which auto-generates getters: data class User(val userId: Int)** (90% success)
   ```
   Use Kotlin data class which auto-generates getters: data class User(val userId: Int)
   ```
3. **Make the field package-private or public if you don't mind breaking encapsulation** (70% success)
   ```
   Make the field package-private or public if you don't mind breaking encapsulation
   ```

## Dead Ends

- **** — Room can still access public fields directly, but it expects getter methods for proper encapsulation and data binding; might cause other issues with data classes. (30% fail)
- **** — This excludes the field from persistence entirely, which is not the intended fix. (90% fail)
- **** — Room uses JavaBeans naming conventions; renaming without adding getter won't solve the problem. (70% fail)
