android-visualizer
android-visualizer copied to clipboard
Cannot initialize Visualizer engine, error: -3
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
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!
you should take permission for record audio.Then it will work prefect.
"android.permission.RECORD_AUDIO" is already there,it crash for some of the devices not for all devices
have u taken run time permission for that?
yes we have taken permission at run time.
Then it should not have any problem? It worked any time or not?
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(); } }
it seems that you dont have handled its result..onRequestPermissionResult..
it's already there ,onRequestPermissionResult we are again calling same method checkPermissionsAndStartVisualization().
then it better to take permission in splash screen and then load visualizer activity page it will work properly.
what is logic behind that?we can take permission at any time. we are always calling initVisualizer() if permission is granted.
but its for safe side...i my case it works prefect..
Is your visualizer is working as per the song beats?
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.
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
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?
guys, did you try to request MODIFY_AUDIO_SETTINGS permission on problematic devices?
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
Follow this to request permission at runtime for API >= 23 Runtime permission
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
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?
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
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.