java.lang.IllegalStateException: Dex archives: setting .DEX extension only for .CLASS files

./gradlew clean fixed the same error for me.


For Cordova developers,

If you get this build error in your project, as said Pierrick Martellière in the comments of this answer, in you project folder use :

cordova clean

It makes a cleaning and a build immediately


It seems I found the solution. At the build moment gradle was showing warnings for me:

Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.

app: 'androidProcessor' dependencies won't be recognized as kapt annotation processors. Please change the configuration name to 'kapt' for these artifacts: 'com.arello-mobile:moxy-compiler:1.5.3' and apply the kapt plugin: "apply plugin: 'kotlin-kapt'".

I made a misspelling and forgot to remove unnecessary annotationProcessor for library:

annotationProcessor "com.arello-mobile:moxy-compiler:$moxyVersion"
kapt "com.arello-mobile:moxy-compiler:$moxyVersion"

So I removed first line.

After that I applied kapt plugin apply plugin: 'kotlin-kapt' and fixed some build errors in code after it.

After all I realized that I forgot to replace compile to implementation in some places. It is weird but without it build didn't work.

This changes fix my error build.