Reputation: 4779
I am trying to write a networked audio application for Android. Code that I previously thought worked is suddenly crashing and burning, with the following output given at the LogCat at error level:
02-19 01:39:42.980 17178-17185/? E/zygote64: Failed sending reply to debugger: Broken pipe
02-19 01:39:43.133 17178-17178/? E/AudioRecord: AudioFlinger could not create record track, status: -1
02-19 01:39:43.133 17178-17178/? E/AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -1.
02-19 01:39:43.134 17178-17178/? E/android.media.AudioRecord: Error code -20 when initializing native AudioRecord object.
That is the entire logcat output for the error level. Even at verbose, there is not more more, and at no point do I get anything pointing me to a line of code where this has crashed.
Nor am I able to find information on what the AudioRecord error code -20 might be. What exactly does that error code portend?
(Note: A typical error with AudioRecord is not to give the app permission to record in the manifest. That is not the case here, I just checked.)
Upvotes: 0
Views: 1782
Reputation: 4779
There seem to be many possible causes of this problem, but it is so terribly documented that it is hard to tell. In this case, however, I had moved from KitKat (API level 19) to Oreo (API level 27).
However, after and including Marshmallow (API level 23) permissions are granted during execution, not at install time. This requires either:
The second solution worked for me. This is alluded to in other answers, including this one, but I did not fully grasp what they were saying. Hopefully spelling this out in detail will help someone else.
Upvotes: 1