I'm getting a build error when trying to run my Flutter project. The build fails with a Gradle exception related to resource and code shrinking. I haven't changed any minifyEnabled or shrinkResources settings. :
FAILURE: Build failed with an exception.
- What went wrong: A problem occurred configuring root project 'android'.
Removing unused resources requires unused code shrinking to be turned on. See http://d.android.com/r/tools/shrink-resources.html for more information.
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
What I Tried:
I ran flutter clean from the terminal, followed by flutter pub get, in an attempt to clear any corrupted build cache.
I then tried to explicitly enable code shrinking by adding minifyEnabled true inside the release block of my app/build.gradle file.
I also tried the opposite approach, disabling resource shrinking by setting shrinkResources false in the same build.gradle file.
What I Was Expecting:
I was expecting flutter clean to resolve any cache-related issues and allow the build to complete successfully, but the build error persisted.
When I added minifyEnabled true, I was expecting the build to succeed because the error message specifically mentioned this was required. The build did succeed, but I'm now facing a new issue (e.g., app crashes, or a specific feature doesn't work), which leads me to believe this might not be the correct solution, or it requires additional configuration.
When I disabled shrinkResources, I was expecting the build to complete successfully without any code or resource optimization, but the same error message appeared, which was unexpected.