To fix this issue, increase the heap memory by updating the following line in android/gradle.properties
:
org.gradle.jvmargs=-Xmx512M
to:
org.gradle.jvmargs=-Xmx8G
Then run:
flutter clean
flutter run
If 8 GB isn’t enough, you can increase it further (e.g., -Xmx16G
).