Audacity adds a gap when exporting mp3

Problem: MP3 File has a gap

This is a known, acknowledged issue since at least 2000:

1 Why is a decoded MP3 longer than the original .wav file?

Because LAME (and all other MDCT based encoders) add padding to the beginning and end of each song. For an explination of why, see the questions below.

800 word long technical explanation pertaining to both decoder and encoder issues snipped.

LAME-enabled players should apparently automatically jump this gap:

LAME embeds the amount of padding in the ancillary data of the first frame of the MP3 file. (LAME INFO tag). The LAME decoder will use this information to remove the leading padding of an MP3 file.

however:

Modifications to the decoder so that it will also remove the trailing padding have not yet been made.

Alternatives

You could try another encoder as mentioned, if you have access to the Fraunhofer version (IIRC it is available in iTunes and Windows Media Player). Alternatively, you may be able to compile/acquire a version of sox with libmad enabled. I think these will have similar issues, however.

The question is, do you definitely need an MP3 as mentioned in the comments? Are you using a player that only handles MP3s?

If it absolutely, definitely, positively has to be an MP3, no ifs ands or buts; and the Fraunhofer encoder also gives the same issue, you could have a look at a previous thread here on SU:

Best program to trim silence beginning and end of mp3 files?