Skip to content
This repository has been archived by the owner on Apr 11, 2022. It is now read-only.

Can not build apk because of insufficient Java Heap Space. #813

Open
qroft opened this issue Jul 11, 2019 · 1 comment
Open

Can not build apk because of insufficient Java Heap Space. #813

qroft opened this issue Jul 11, 2019 · 1 comment

Comments

@qroft
Copy link

qroft commented Jul 11, 2019

I can not create my app as it contains thousands (!) of images (approx. 2.8GB in total ) and the build process stops by informing me that it has a Java Heap Space problem.
For the last days i have read everything about Java Heap Space and added several gradle.properties files to my projcect's root, sub folder Android etc. but the strange thing is that even with these files inside, the Phonegpa ClI shows me this info:

Running command: cmd "/s /c "C:\phonegaps\remgif\platforms\android\gradlew.bat cdvBuildRelease -b C:\phonegaps\remgif\platforms\android\build.gradle -Dorg.gradle.daemon=true -Dorg.gradle.jvmargs=-Xmx2048m""

So even if i change the Xmx to 4g (my PC has 8 GB of RAM), the command "phonegap build -release android -d" always seems to use the 2048MB

As soon as i delete three folders with hundreds of images inside, the APK is created.
So i am wondering is this is a RAM or APK max size problem !?

PhoneGap CLI, node & npm versions

Phonegap 8.2.2.
Node 8.11.3
NPM 6.10.0

Expected Behaviour

APK gets build

Actual Behaviour

Build stopped due to "Java Heap Space" fail

Steps to Reproduce

phonegap build -release android

Sample Code that illustrates the problem

n.A.

Error messages

  • What went wrong:
    Execution failed for task ':app:packageRelease'.

Java heap space

@qroft
Copy link
Author

qroft commented Jul 11, 2019

[UPDATE]
I removed all the images and build the app - everything is fine.
After searching around i tried this solution:

  • created my app-unsigned.apk (approx. 5MB, without images)
  • renamed that apk to app-unsigned.zip and opend it
  • moved all my images inside that zip folder and closed 7zip
  • the now 2.8GB big file is called app-unsigned.zip
  • renamed it back to app-unsigned.apk

When i now try to
zipalign -v 4 app-unsigned.zip hello.apk
i get this error:
Unable to open 'app-unsigned.apk' as zip archive

What i now have found out:
zipalign does not like files bigger than 2gb :(

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant