Why does sound on Android play at double speed and crackle?

I’m trying to get some sound working in a Unity project at the moment. The sound works perfectly fine in the Editor and in the iOS build.

When building for Android, however, the music makes a crackling/popping/static noise, and plays twice as fast. I’ve checked audio.pitch and it’s set to 1 (and anyway, the pitch of the audio is not different, it’s just as if half of the “audio frames” are missing). This applies to all my sounds.

I’ve tried:

  • Changing the sound from 2D to 3D and back
  • Changing compression to native
  • Changing compression amount
  • Changing load type
  • Forcing the sound to mono
  • Changing the Audio settings default speaker set up to mono
  • Using AudioSource.PlayClipAtPoint instead of an AudioSource component
  • Changing pan level when the sound was a 3D sound
  • Checking bypass effects
  • Playing on awake vs. starting from script
  • Testing on multiple devices

The sound files definitely play correctly outside of Unity (and in the Editor and iOS). Native Android sound files play correctly on the phone.

I can’t think of what else could cause this, especially the playing twice as fast.

For now, I’m going to make the background music file into a native Android sound (though that breaks the abstraction barrier) and leave the smaller sound effects as they are (they don’t seem to be as bad).

EDIT: My project is actually used as a library inside a larger native Android project. I normally test by exporting, then running my shell project. I just tested by exporting the Unity project straight to my phone and the sound worked fine. It looks like somehow my native Android code is interfering with the Unity music. Does anybody know how the Unity sound system works in terms of Android? Any thoughts on how my code could be interfering with it? I’m using a MediaPlayer to play some sounds in the native Android shell also.

Here’s how I ended up fixing it: Project settings > Audio > Default Speaker Mode to Stereo. When it’s in mono, it caused the issue I was having.

I have been struggling with a same problem for few days and finally found the solution which worked for me, so I decided to share if someone stumbles upon this old thread.

You must not extend UnityPlayerActivity in Eclipse but plain Activity and sound issues are gone.

Check audio sampling, if it’s too high like 96KHz then sound can be distorted.