Not a solution as much as a work around. I ultimately had to shrink the database by being more selective with my field contents.
Indexes also took up a lot of space so I had the app generate them after it loaded.
Like I said - a workaround, not a fix.
I found that none of the switches or settings that were recommended for adjusting the heap size did anything.
I find it very difficult to tell which setting and/or switch ultimately applies to the build. The lack of cohesive and comprehensive documentation has relegated Ionic to very specific use cases for me.
What you are having problems with is the build process executed by Cordova. You might have more luck searching with “Cordova” instead of “Ionic” as Ionic only “proxies” the call to the Cordova CLI that then uses e.g. the Android SDK to build the app.
That’s a good suggestion. The challenge is that each component in the series of proxies is unaware of being used as a proxy by the overall process. So each set of documentation exists independently, with no reference to the other parts.
The Ionic to Cordova to Android SDK build process makes it very difficult to trouble shoot a configuration setting that is being passed from Ionic through the aforementioned proxy chain.
In this case, I tried adjusting the settings all through the build pipeline but gave up when I couldn’t determine where the actual applied setting was coming from and nothing made any difference.
Any insight into this heap size setting problem would be appreciated.
To be honest I could never help anybody with heap issues yet as I have no experience with them.
But I know that Ionic CLI literally just calls cordova build android - so if you do so yourself you should get the exact same error message as with ionic cordova build android.
I managed to fix my build with the tip from @Sujan12.
running cordova build android -d shows that no matter what you have in gradle.properties or environment, the build get’s executed with -Dorg.gradle.daemon=true -Dorg.gradle.jvmargs=-Xmx2048m -Pandroid.useDeprecatedNdk=true
The Cordova file ./platforms/android/cordova/lib/builders/GradleBuilder.js in the project folder
is responsible for hardcoding the maximum heap size:
// to allow dex in process
args.push('-Dorg.gradle.jvmargs=-Xmx2048m');
Increasing the maximum heap to 4g made my build successful.
Good Luck.
I was running into this same problem but your workaround of increasing heap size to 4g basically told me that that heap size to too big. Hmm.
Turns out I was running JDK 1.8 (32 bit) instead of 64 bit. Some older software was requiring 32 bit. I read somewhere that the heap size limit on 32 bit is 1-1.5g and 64 bit is limited to total free memory.
So after updating JDK to 64bit and following above workarounds, all is well!!!