4

In the sample AudioFxDemo.java, provided with the SDK, I get a

java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -4

when trying to create the android.media.audiofx.Visualizer

mVisualizer = new Visualizer(mMediaPlayer.getAudioSessionId());

(AudioFxDemo.java:173).

As far as I can see, the error originates in the native code, (lines 266 ff.) An error also happens when trying to create the android.media.audiofx.Equalizer:

mEqualizer = new Equalizer(0, mMediaPlayer.getAudioSessionId());

(AudioFxDemo.java:98)

I get a

java.lang.IllegalArgumentException: Effect type: 0bed4300-ddd6-11db-8f34-0002a5d5c51b not supported.

I have declared the following permissions for my project:

<uses-permission android:name="android.permission.RECORD_AUDIO"
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>

Any ideas what might be going wrong here?

It seems to be a problem with the API level. I have no problems on Gingerbread (API Level 10). I have only tested on virtual devices.

N.N.
  • 8,336
  • 12
  • 54
  • 94
Igor F.
  • 2,649
  • 2
  • 31
  • 39

2 Answers2

4

This seems to be an issue with the Emulator. I have tested on an actual device running Android 4.0.3 and it worked just fine.

Jona
  • 13,325
  • 15
  • 86
  • 129
  • I encountered the same issue. I was having issued running on the emulator but did not experience them when running on an actual device. – d.moncada Nov 08 '12 at 18:10
  • i have implemented same thing. But it is crashing on Emulator and working perfect in real device. What should be cause of this issue? – Shreyash Mahajan Apr 30 '13 at 05:13
  • I am having the same issue with real world device running Android 6.0 marshmallow. And I have added every required permission – TheOnlyAnil Mar 17 '16 at 05:36
2

it seems issue on some android devices. I got this crash http://pastebin.com/7kqPbxkV on Lenovo a369i SDK version 17. For now only thing i`ve found is to check if equalizer effect is supported on device:

boolean supports_equalizer=false;
AudioEffect.Descriptor [] effects = Equalizer.queryEffects();
for (AudioEffect.Descriptor lDescriptor:effects){
   if (Build.VERSION.SDK_INT>=18) { //Equalizer present only starting with API 18. Cam try to hardcode its UUID
     if (AudioEffect.EFFECT_TYPE_EQUALIZER.equals(lDescriptor.uuid)){
        supports_equalizer=true;
     }
   }
}
Alexandr
  • 170
  • 2
  • 8