Android Question [solved] AudioStreamer and "not initialized" exceptions

Dave O

Active Member
Licensed User
If you're trying to record audio using AudioStreamer (via the internal Audio library), and you're getting exceptions when you try to start recording ("uninitialized AudioRecord object"), it may be because of permissions - specifically runtime permissions.

I downloaded Erel's AudioStreamer examples and they worked fine, but when I copied the code to my own app, it threw an exception when I tried to start recording audio.

It took a while to figure out that Erel's example app was targeting Android 4.x (that's when it was written), so the old permissions rules applied, and it worked fine.

But my own app, targeting SDK 26 (per the new Play Store rules), had to use the new permissions rules, which involve runtime permissions (as Erel describes here).

Once I added the runtime permissions (a couple lines of code), everything worked fine in my app.

I hope this saves the next person some time and hair-pulling. o_O