As previous answers stated just immersion is enough to learn a foreign language. However, it works only if we are talking about the same species. All humans have a capability (excluding special disability cases) to hear and produce all sounds that human languages comprise. It may take quite some time, but with a sufficient training, even elders can learn to distinguish sounds and produce them more or less accurately. It works even for the most phonetically and grammatically distant human languages.
The acquisition of new hearing and speaking skills also depends on an importance of phonetic peculiarities for conveying meanings. For example, in Australian English and Japanese, the vowel's length changes the meaning, e.g. fairy [feːɹi] and ferry [feɹi], span (as in wing span) and span [spæn](past tense of spin); おばあさん (obaasan — grandmother) and おばさん (obasan — aunt), おじいさん (ojiisan — grandfather) and おじさん (ojisan — uncle). In Russian, the sound length is less important, however, stress of syllables and firmness of the consonants can be crucial: зАмок (zAmok — castle) and замОк (zamOk — lock), Лен (Len — the name Lena in the vocative case [colloquial Russian]) and лень (len' — laziness). Accordingly, learners of Australian English and Japanese become better at distinguishing length of vowels (and correctly articulating them), while learners of Russian improve their consonant and stress skills. It is not a rocket science. It is just a matter of practice and exposure to native speakers.
The real problem appears when we are talking about an alien language. One the valid points that Arrival makes is that learning writing can be easier than a spoken language. If aliens have a very different biology humans might not be able to hear or produce the sounds of an alien language. A specialised equipment might be the only way to deal with this case. A language that combines phonetical component with some form of a body language, e.g. gestures, change of skin colour, etc., may pose even greater problems since human bodies might be utterly different in appearance, bone structure, and functions. Equipment might help, but also might not.
As in Arrival, learning a written language can be an easier route in the above-mentioned situation. Of course, that is assuming that both aliens and humans are able to perceive writings of each other and have means to reproduce them. If aliens do not have a writing system, newcomers can teach them. Probably, recruiting some children or elders would be the most beneficial for a writing project since it takes more time.
If both sides, aliens and humans, are interested in communication, they will probably develop a new language that can accommodate limitations of both sides. This lingua franca will be simpler and less nuanced, but it will get messages across and things done. Lingua francas also develop in human populations, of course. But usually it happens when many speakers of two or more languages (likely distant) live together or perform some important activity, for example, trade. If you have a very small group of foreigners among a huge group of locals, the newcomers are forced to learn a local language. Although, some borrowing from their language can also occur.
I think that depending on the numbers of your characters and locals something like a lingua franca is very possible. It might also add some flavour to the language of your story.
While a potion or a mysterious artefact could speed up the learning process, personally, I would more interested in a story that does not use this shortcut. Language learning situations are ideal for a comic relief. They can also trigger some major plot events. It might be hard to write but I am sure the readers would appreciate the effort.