I have wanted to make something like a rhythm game for Android in Unity, and for that I needed to write an audio manager to play my songs and sound effects in-game. I have followed Brackeys' tutorial for that, and it worked fine for me, even with sounds up to 5 minutes long.
Now I have built the game for Android, but if I press a button to play this song, it does not work at all any more. Sometimes the build just crashes, sometimes nothing happens, and most of the time the whole app freezes for about 5 to 10 seconds, and then the sound plays.
Also, in a Windows build this does not happen, and in-editor it works perfectly fine as well.
I have tried setting the audio to Best Latency, I have reimported all assets multiple times, and nothing worked.
Any help is highly appreciated because this is my first project! ( Also I'm not so good in English so sorry for that :) )
Update:
LevelManager.cs
using UnityEngine; using System; public class LevelManager : MonoBehaviour { public Level[] levels; void Awake() { foreach (Level s in levels) { s.source = gameObject.AddComponent<AudioSource>(); s.source.clip = s.clip; s.length = s.clip.length; } } public void Play(string name) { Level s = Array.Find(levels, sound => sound.name == name); if (s == null) { Debug.LogWarning("Sound: " + name + " not found!"); return; } s.source.Play(); } } Level Class
using UnityEngine; [System.Serializable] public class Level { [Header("General")] public string name; [HideInInspector] public float length; [Header("Audio")] public AudioClip clip; [HideInInspector] public AudioSource source; } This is the import setting for one of the sounds.

