Erdogan's rants are aimed at the Turkish population in Turkey, NOT Germany. He builds nationalism at home. He is trying to provoke the EU to the extent that he is not held responsible for Turkey's failure to become an EU member - Erdogan simply does not want EU membership, but he could never say that openly, so he needs to provide a reason as to why it is not tenable!
Erdogan does indeed act outrageously to the point that it is hard to believe Turkey's EU application is still on track. If this is the game he is playing, he can probably hardly believe how weak and timorous Europe's leaders are. I know I cannot.
Lending plausibility to the theory is the fact that Erdogan was previously associated with the recently deceased Necmettin Erbakan, Turkey's first jihadist Prime Minister, who was forced to resign by the military, and who opposed EU membership and wanted Turkey to turn east instead. Turkish support for joining the EU has indeed declined steeply in the last few years, partly because of the insulted national pride about not being welcomed with open arms. Could it all be a Machiavellian plot by Erdogan to precipitate Turkey's rejection by the EU without getting the blame?
Ultimately, I'm not convinced by this theory, but it does provide some interesting food for thought.