I know this is a very late answer, but I also struggled with this problem and I want to share my experience.
First, as the answer mentioned above, permission
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
and if sound source 0 is used ( Visualizer(0); //system mix ),
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
. After adding permissions to my application and installing the (new compiled) application again, my application still crashed. I found out that the device needs to be restarted in order to use Visualizer without any exceptions (for some reason). Therefore, if you are developing an application and get this exception, you may need to reboot after adding permissions to the application .
Fruchtzwerg
source share