0

I'm developing an Android app in Android Studio and today suddenly it doesn't compile when I press the "Run" button. The error is this:

Error:Execution failed for task ':app:packageInstantRunResourcesDebug'. Java heap space

I've tried cleaning the project and rebuilding it but it didn't work.

trincot
  • 317,000
  • 35
  • 244
  • 286
Josemafuen
  • 682
  • 2
  • 16
  • 41
  • looks like you ran out of memory, can you check the ram usage of your pc, or the java max ram settings? – DZDomi Jan 07 '18 at 21:07
  • This might help you [How to fix Java heap space](https://stackoverflow.com/questions/41645747/android-studio-gradle-build-failing-java-heap-space) – Napster Jan 07 '18 at 21:08
  • I already tried adding `org.gradle.jvmargs=-XX\:MaxHeapSize\=256m -Xmx256m` to my gradle.properties but it didn't work – Josemafuen Jan 07 '18 at 21:11
  • Ram usage on my PC is at 50% so I don't think that's the problem – Josemafuen Jan 07 '18 at 21:15
  • `256m` is probably lower than what you started with. Set it higher, such as `1024m`. "Ram usage on my PC is at 50% so I don't think that's the problem" -- that means nothing in this case. – CommonsWare Jan 07 '18 at 21:31
  • Not working, I tried even with 2048 – Josemafuen Jan 07 '18 at 22:19
  • Possible duplicate see https://stackoverflow.com/questions/39547100/error-in-build-gradle-in-android-studio for more solutions – Crigges Jan 08 '18 at 00:01

1 Answers1

0

I have tried many solutions but finally, this helped me to solve this problem : -

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

use this line in your "gradle-wrapper.properties". hope it helps others too.

Gourav Samre
  • 134
  • 1
  • 7