'Error: Out of memory: Java heap space. Configure Gradle memory settings using '-Xmx' JVM option

when in create new project in android studio i get this error

"Out of memory: Java heap space. Configure Gradle memory settings using '-Xmx' JVM option (e.g. '-Xmx2048m'.)

Please fix the project's Gradle settings.



Solution 1:[1]

In my case Invalidate cache and restart the android studio(which is automatically restarted) then an error will go after restarting the android studio

File-> Invalidate cache/restart-> Invalidate and restart

enter image description here

then enter image description here

I hope you will find the answer... please share your feedback

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1