# java.lang.RuntimeException: start failed. E/MediaRecorder: start failed: -19

- **ID:** `android/media-recorder-start-failed`
- **Domain:** android
- **Category:** runtime_error
- **Error Code:** `-19`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

MediaRecorder cannot start due to missing audio/video source permissions, invalid output file path, or unsupported encoder/format combination.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Android 12 (API 31) | active | — | — |
| Android 13 (API 33) | active | — | — |

## Workarounds

1. **Ensure all required permissions are granted: add <uses-permission android:name="android.permission.RECORD_AUDIO" /> and <uses-permission android:name="android.permission.CAMERA" /> in AndroidManifest.xml, and request them at runtime.** (85% success)
   ```
   Ensure all required permissions are granted: add <uses-permission android:name="android.permission.RECORD_AUDIO" /> and <uses-permission android:name="android.permission.CAMERA" /> in AndroidManifest.xml, and request them at runtime.
   ```
2. **Use a valid output file path in the app's external cache directory. Example: File outputFile = new File(context.getExternalCacheDir(), "recording.mp4"); mediaRecorder.setOutputFile(outputFile.getAbsolutePath());** (90% success)
   ```
   Use a valid output file path in the app's external cache directory. Example: File outputFile = new File(context.getExternalCacheDir(), "recording.mp4"); mediaRecorder.setOutputFile(outputFile.getAbsolutePath());
   ```
3. **Set the audio and video encoders to supported values. Example: mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);** (85% success)
   ```
   Set the audio and video encoders to supported values. Example: mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
   ```

## Dead Ends

- **** — Video recording with audio requires both CAMERA and RECORD_AUDIO permissions; missing audio permission causes start failure. (75% fail)
- **** — MediaRecorder requires a writable file path; using a non-writable location leads to error -19. (80% fail)
- **** — Not all devices support H.265; falling back to H.264 is safer but the error persists if not handled. (70% fail)
