I got reports of this error occuring in my Menu Starter Kit marketplace asset. Sometimes the error only appeared during packaging causing the build to fail. I also created the plugin in 4.15 and updated it for 4.16, 4.17 and 4.18. The reporters were all using 4.17 or newer. However I have not been able to reproduce the issue myself so far, and thus couldn’t do any debugging myself. Maybe the issue you are describing and the reports I got are related.
Could you message me your example project, so I can test this issue on my side too? I can also upload it to a shared cloud folder for you, if you want.