# java.lang.IllegalArgumentException: Can't convert value to Intent, class android.content.Intent is not a valid type

- **ID:** `android/activityresult-api-contract-mismatch`
- **Domain:** android
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 87%

## Root Cause

ActivityResultContract expects a different input/output type than the one provided in registerForActivityResult.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| AndroidX Activity 1.7.2 | active | — | — |
| Android 14 (API 34) | active | — | — |
| Kotlin 1.9.0 | active | — | — |

## Workarounds

1. **Ensure the contract matches the input type. For Intent, use ActivityResultContracts.StartActivityForResult() and pass Intent explicitly: registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> ... }** (90% success)
   ```
   Ensure the contract matches the input type. For Intent, use ActivityResultContracts.StartActivityForResult() and pass Intent explicitly: registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> ... }
   ```
2. **If using custom contract, override createIntent correctly. Example: class CustomContract : ActivityResultContract<Uri, Boolean>() { override fun createIntent(context: Context, input: Uri) = Intent(Intent.ACTION_VIEW, input) }** (85% success)
   ```
   If using custom contract, override createIntent correctly. Example: class CustomContract : ActivityResultContract<Uri, Boolean>() { override fun createIntent(context: Context, input: Uri) = Intent(Intent.ACTION_VIEW, input) }
   ```

## Dead Ends

- **Use ActivityResultContracts.StartActivityForResult() without any type casting** — Still throws same error if Input class is not Intent; contract requires explicit type conversion. (80% fail)
- **Remove the contract entirely and use deprecated startActivityForResult** — Deprecated and won't compile on targetSdk 34+; also breaks modern lifecycle handling. (90% fail)
