When building Flutter projects I noticed that sometimes, Gradle task 'assembleDebug' would run even if I had already built the project successfully earlier, and it downloads upto 500MB or sometimes almost 1GB of downloads. If I make changes to the code and try to run it again, the Gradle task 'assembleDebug' does some 200MB or 300MB of downloads again just to be able to build the APK. So I had a look at the size of the folders and found transform outputs for specific dependency variants. Gradle appeared to create separate folders because transforms are variant specific. Each project+ABI+build type+dependency version probably creating a new transform cache and flutter's AOT engine resulting in native `libflutter.so` files multiplying across architectures.
When I raised this as an issue, the Flutter developers asked for details and tried to dismiss it as an environment issue on my computer. But I kept investigating and found that adding `org.gradle.caching=true` to `<my_flutter_app_folder>/android/gradle.properties` solved the problem. I did a bit more digging and added two more lines. This is all you need to add to the `gradle.properties` file:
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.daemon=true

No comments:
Post a Comment