This post would demo how to do solve the TaskExecutionException e.g. transform Classes With Android Gradle Class Shrinker For Debug as follows:
- Android Studio 3.1
- Android SDK tools 26.1.1
3. The Project layout
I have setup the project with two modules as follows:
The base have some common android base classes and utilities. The app module is the real module for my application.And the app depends on the base.
4. The project’s build.gradle file
Here is the build.gradle of the project:
5. The app module’s build.gradle file
Here is the build.gradle of the app module
6. The problem
When I build the project, everything works fine. But when I run the app and deploy to an emulator, I got this Exception:
Warnings found during shrinking, please use -dontwarn or -ignorewarnings to suppress them.
Just as this picture shows:
When I click the gradle build warning, I got this:
6. How to solve the problem?
Change the app’s build.gradle file to the following:
That is, the key is to change the debug buildtype’s minifyEnabled to false
As the google officical document says:
To enable code shrinking with ProGuard, add minifyEnabled true to the appropriate build type in your build.gradle file.
Be aware that code shrinking slows down the build time, so you should avoid using it on your debug build if possible.
7. Other solutions
I have tested that there is another solution to this problem, You can edit the app’s build.gradle as follows:
or like this:
It’s clear that the minifyEnabled must work collaborated with the useProguard, if you set minifyEnabled to be true but turn off the useProguard, then the exception would popup.