Android Studio 3.0 Execution failed for task: unable to merge dex
This error happens when you add an external library which may not be compatible with your compileSdkVersion
.
Be careful when you are adding an external library
.
I spent 2 days on this problem and finally it got solved following these steps.
Make sure all your support libraries are same as
compileSdkVersion
of yourbuild.gradle(Module:app)
in my case it is26
.In your defaultConfig category type multiDexEnabled true. This is the important part.
Go to File | Settings | Build, Execution, Deployment | Instant Run and try to Enable/Disable Instant Run to hot swap... and click okay
Sync
Your project.Lastly, Go to Build | click on Rebuild Project.
Note: Rebuild Project first cleans and then builds the project.
Try to add this in gradle
android { defaultConfig { multiDexEnabled true } }