Build fails. Execution failed for task ..DexArchive

Sometimes the build suddenly fails on erros like:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
or
Execution failed for task ':app:processDebugResources'.

and I changed nothing or harmless code that has nothing to do with.
What’s the problem? Maybe random data loss?
That’s a weird bug.

Now I removed the folders plugins and platforms and it works. Still weird. It seems like the build process sometimes destroy some files / content / settings. This is a bug.