Solution: Access to the dex task is now impossible, starting with 1.4.0

Everybody* who wants to upgrade to and above 1.4.0 build tool version is getting this error.

Error:Access to the dex task is now impossible, starting with 1.4.0
1.4.0 introduces a new Transform API allowing manipulation of the .class files.
See more information: http://tools.android.com/tech-docs/new-build-system/transform-api

Error:Access to the dex task is now impossible, starting with 1.4.0
1.4.0 introduces a new Transform API allowing manipulation of the .class files.
See more information: http://tools.android.com/tech-docs/new-build-system/transform-api

As you can see by visiting the new build system: transform api that there is no solution provided.

Follow the steps to solve the problem Access to the dex task is now impossible:

1. Update all the libraries (dependencies from Google Play Services and Support libraries along with other SDKs used) to the max available version. If you are using NewRelic, then update to the latest version.
2. Add multiDexEnabled true to the defaultConfig in /app/build.gradle.




3. Remove all the code you have previously written to get MultiDexing to work.
For instance,

If you are using custom Application class by extending android.app.Application, then remove MultiDex.install(base);

4. Update the build tool version to 2.1.2 in <project>/build.gradle

5. Gradle Sync the project, by clicking Sync now

*Those who have crossed the 64K method limit for dex compilation. Solution is known as MultiDex.

About Krrishnaaaa

Socially known as Navkrishna.. An Android application developer. He likes to create tutorials and post them here or on YouTube or GitHub.. All these activities are shared on Facebook, Twitter, and G+ page.