Android resolver: Resolution failed "java heap"

Recently I have installed GoogleMobileAds for my project, but when trying to resolve dependencies with ExternalDependencyManager it gave me error “Could not create an instance of type org.gradle.initialization.DefaultSettings_Decorated.” So I fixed that by looking at the gradle project Unity was trying to create and replacing gradle-wrapper “distributionUrl=https://services.gradle.org/distributions/gradle-5.1.1-bin.zip” with the newer version.And that worked… For like 5 seconds. Then It gave me the error “Java heap space” so I thought that JVM hadn’t enough memory for it so I changed gradle.properties in Users/My User/.gradle to have instead 14gb of memory. Basically all the memory I had so I added “org.gradle.jvmargs=-Xmx14g” and it got like 3 or 4 lines closer to the end. And thats that. I have been tickling
this issue for weeks. Any help appreciated. My Unity version is “6000.0.19f1”.