The idea of putting an insect inside a hollow object, like an apple, blown egg, gourd, ring, etc., to make it move mysteriously was recorded in a late fifteenth century notebook by Thomas Betson, a monk at Syon Abby in Middlesex. This notebook is at St. John's College, Cambridge, MS. E.6, according to Richard Kieckhefer in Magic in the Middle Ages, 1989, p. 91. Betson used a beetle in a hollowed apple. In Gibecière, Vol. 2 No. 2, Summer 2007, p. 183, Vanni Bossi claimed that early Japanese books feature eels in gourds for the purpose.
An early published source of the same apple/beetle combination is Thomas Hill's Naturall and Artificiall Conclusions, 1567, n.p. Later in the same book, Hill described a similar feat of causing an egg to fly away by inserting a winged insect into a hollow egg. It probably sounded good at the time, but the method cannot work due to science.
Another early source for this trick is Horatio Napolitana's pamphlet, Libretto de Secreti Noblissimi et Alcuni Giocchi con Destrezza di Man, Cose Vere e Experientate., 1585, n.p., making David Hoy's well-known insect in a Ping-pong ball idea from The Bold and Subtle Miracles of Dr. Faust, 1963, p. 19, a very late entry.