Open umeshsarkar opened 6 years ago
Pay attention to these lines, this is the cause of your error:
java.lang.RuntimeException: Unable to start service com.topgamesandapps.audiorecorder.RecordingService@1cedefa with Intent { cmp=com.topgamesandapps.audiorecorder/.RecordingService }: java.lang.RuntimeException: setAudioSource failed.
Caused by: java.lang.RuntimeException: setAudioSource failed.
at android.media.MediaRecorder.setAudioSource(Native Method)
at com.topgamesandapps.audiorecorder.RecordingService.startRecording(RecordingService.java:93)
Investigate the stack trace carefully, it usually contains enough information to pinpoint an exception cause.
I did change with targestSdkVersion 27 and some other changes. After that while, I m click on record button application gets crashed.
Error Log
--------- beginning of crash 08-13 16:24:26.409 15009-15009/com.topgamesandapps.audiorecorder E/AndroidRuntime: FATAL EXCEPTION: main Process: com.topgamesandapps.audiorecorder, PID: 15009 java.lang.RuntimeException: Unable to start service com.topgamesandapps.audiorecorder.RecordingService@1cedefa with Intent { cmp=com.topgamesandapps.audiorecorder/.RecordingService }: java.lang.RuntimeException: setAudioSource failed. at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3491) at android.app.ActivityThread.-wrap20(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) Caused by: java.lang.RuntimeException: setAudioSource failed. at android.media.MediaRecorder.setAudioSource(Native Method) at com.topgamesandapps.audiorecorder.RecordingService.startRecording(RecordingService.java:93) at com.topgamesandapps.audiorecorder.RecordingService.onStartCommand(RecordingService.java:77) at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3474) at android.app.ActivityThread.-wrap20(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
RecordingService.java line no.
75 @Override 76 public int onStartCommand(Intent intent, int flags, int startId) { 77 startRecording(); 78 return START_STICKY; 79 } . . . . 92 mRecorder = new MediaRecorder(); 93 mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); 94 mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); .