android-visualizer icon indicating copy to clipboard operation
android-visualizer copied to clipboard

Cannot initialize Visualizer engine, error: -3

Open ominfowave opened this issue 7 years ago • 23 comments

Fatal Exception: java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -3 at android.media.audiofx.Visualizer.(Visualizer.java) at com.myApplication.android_visualizer.visualizer.VisualizerView.link(VisualizerView.java:85) at com.myApplication.activities.RadioStationActivity.initVisualizer(RadioStationActivity.java:633) at com.myApplication.activities.RadioStationActivity.checkPermissionsAndStartVisualization(RadioStationActivity.java:537) at com.myApplication.activities.RadioStationActivity.onPlayingStarted(RadioStationActivity.java:525) at com.myApplication.services.RadioService.onPrepared(RadioService.java:197) at io.vov.vitamio.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:1704) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6692) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

Some time application get crash with this log

ominfowave avatar Jun 29 '17 03:06 ominfowave

Are you using audio session 0? What API are you targeting? I just updated a bunch of libraries and my Android API to 26 and started getting the same initialization error. Will try rolling back the level tomorrow. Hoping they aren't fully deprecating this functionality, especially without documenting it!

cypherdare avatar Jul 04 '17 05:07 cypherdare

you should take permission for record audio.Then it will work prefect.

mansim96 avatar Aug 03 '17 09:08 mansim96

"android.permission.RECORD_AUDIO" is already there,it crash for some of the devices not for all devices

ominfowave avatar Aug 03 '17 09:08 ominfowave

have u taken run time permission for that?

mansim96 avatar Aug 03 '17 09:08 mansim96

yes we have taken permission at run time.

ominfowave avatar Aug 03 '17 09:08 ominfowave

Then it should not have any problem? It worked any time or not?

mansim96 avatar Aug 03 '17 09:08 mansim96

there are many crash reports on fabric,normally it working ,i have taken permission this way

private void checkPermissionsAndStartVisualization() { if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECORD_AUDIO}, REQUEST_PERMISSION_RECORD_AUDIO); } else { initTunnelPlayerWorkaround(); initVisualizer(); } }

ominfowave avatar Aug 03 '17 09:08 ominfowave

it seems that you dont have handled its result..onRequestPermissionResult..

mansim96 avatar Aug 03 '17 09:08 mansim96

it's already there ,onRequestPermissionResult we are again calling same method checkPermissionsAndStartVisualization().

ominfowave avatar Aug 03 '17 09:08 ominfowave

then it better to take permission in splash screen and then load visualizer activity page it will work properly.

mansim96 avatar Aug 03 '17 09:08 mansim96

what is logic behind that?we can take permission at any time. we are always calling initVisualizer() if permission is granted.

ominfowave avatar Aug 03 '17 09:08 ominfowave

but its for safe side...i my case it works prefect..

mansim96 avatar Aug 03 '17 09:08 mansim96

Is your visualizer is working as per the song beats?

mansim96 avatar Aug 03 '17 09:08 mansim96

Has anyone found the solution for this? It happens rarely, only on some devices even if android.permission.RECORD_AUDIO is handled in the correct way. I also noticed that it started to happen at Android API to 26.

mobilevisuals avatar Apr 05 '18 13:04 mobilevisuals

I'm having this issue as well. Initially using an audio session id of 0, but now even when I grab the ExoPlayer's session id directly from my background service it still happens

olliejm avatar May 14 '18 22:05 olliejm

This also happens to my visualizers on some devices, like described above. Runtime permissions are used correctly. Is it caused by bad drivers on poor devices?

mobilevisuals avatar Sep 05 '19 13:09 mobilevisuals

guys, did you try to request MODIFY_AUDIO_SETTINGS permission on problematic devices?

mykola-dev avatar Jun 04 '20 14:06 mykola-dev

I also found same issue I have added permissions: <uses-permission android:name="android.permission.RECORD_AUDIO"/> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/> <uses-permission android:name="android.permission.INTERNET"/> And verified it has permission still getting this issue

E/AudioEffect: set(): AudioFlinger could not create effect e46b26a0-dddd-11db-8afd-0002a5d5c51b / , status: -2 E/visualizers-JNI: Visualizer initCheck failed -3 E/Visualizer-JAVA: Error code -3 when initializing Visualizer. I have tried to set audio player's session ID "1009" (mAudioPlayer.getAudioSessionId();) and "0" also but none is working

anantshah93 avatar Sep 15 '20 16:09 anantshah93

Follow this to request permission at runtime for API >= 23 Runtime permission

cleverchuk avatar Nov 24 '20 20:11 cleverchuk

Hello people

I am programming in a own project and had this same problem to initialize the Visualizer with an audio session id of 0 In my case, I am programming for a minSdkVersion 16 and a targetSdkVersion 30

I fixed this problem by adding to my app permission to write to external storage My current permissions in AndroidManifest.xml file are the following:

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

I hope I was able to help you Greetings

-> Sorry for my English

p3t3r4x avatar Mar 31 '21 18:03 p3t3r4x

This is still happening to me and the last suggested fix by adding the WRITE_EXTERNAL_STORAGE did not work either (Android 11). Any updates on this?

seriouslyhypersonic avatar Oct 06 '21 15:10 seriouslyhypersonic

This is still happening to me and the last suggested fix by adding the WRITE_EXTERNAL_STORAGE did not work either (Android 11). Any updates on this?

.. there is a typo in @p3t3r4x 's post

<use-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE "/> <---- remove trailing white space in the permission's name

lorenzfischer avatar Jul 14 '22 20:07 lorenzfischer

This is still happening to me and the last suggested fix by adding the WRITE_EXTERNAL_STORAGE did not work either (Android 11). Any updates on this?

.. there is a typo in @p3t3r4x 's post

<use-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE "/> <---- remove trailing white space in the permission's name

Hi @lorenzfischer, thanks for finding this little bug, I've already edited and fixed it.

p3t3r4x avatar Jul 14 '22 21:07 p3t3r4x