Receiver not registered: org.fmod.FMOD$PluginBroadcastReceiver

Sometimes android application crashes with the following error:

F java_vm_ext.cc:577] JNI DETECTED ERROR IN APPLICATION: JNI GetStaticMethodID called with pending exception java.lang.IllegalArgumentException: Receiver not registered: org.fmod.FMOD$PluginBroadcastReceiver@2ae2bba
F java_vm_ext.cc:577] at android.content.IIntentReceiver android.app.LoadedApk.forgetReceiverDispatcher(android.content.Context, android.content.BroadcastReceiver) (LoadedApk.java:1459)
F java_vm_ext.cc:577] at void android.app.ContextImpl.unregisterReceiver(android.content.BroadcastReceiver) (ContextImpl.java:1642)
F java_vm_ext.cc:577] at void android.content.ContextWrapper.unregisterReceiver(android.content.BroadcastReceiver) (ContextWrapper.java:715)
F java_vm_ext.cc:577] at void android.content.ContextWrapper.unregisterReceiver(android.content.BroadcastReceiver) (ContextWrapper.java:715)
F java_vm_ext.cc:577] at void org.fmod.FMOD.deregisterHeadsetDetection() (FMOD.java:156)
F java_vm_ext.cc:577]
F java_vm_ext.cc:577] in call to GetStaticMethodID

This is most likely to occur if you call System::initialize before org.fmod.FMOD.init

You should be able to solve this by ensuring that org.fmod.FMOD.init happens before system initialize.

You should be able to solve this by ensuring that org.fmod.FMOD.init happens before system initialize.

Thanks, that helped to fix one of the issues. I have one more bug report when the same issue is happening in Activity.onDestoy():

_pCoreSystem->mixerSuspend();

...

FMOD.close();

Before Application.onDestroy is called, you will want to call Studio::release followed by org.fmod.FMOD.close