I'm trying to build a Trusted Web Activity (TWA) project using the Bubblewrap CLI on Windows, but I keep encountering an error when running the gradlew.bat assembleRelease
command. Here's the full error message:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized JVM option is used. For more details on the daemon, please refer to .8/userguide/gradle_daemon.html in the Gradle documentation.
...
Error occurred during initialization of VM
Could not reserve enough space for 1572864KB object heap
Environment details:
- OS: Windows
- Java: Installed via Bubblewrap
- Gradle: Version 8.8
- Bubblewrap CLI: Latest version (installed via npm)
Does anyone have suggestions for resolving this issue? Is there something I'm missing?
Any help would be greatly appreciated!
I'm trying to build a Trusted Web Activity (TWA) project using the Bubblewrap CLI on Windows, but I keep encountering an error when running the gradlew.bat assembleRelease
command. Here's the full error message:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized JVM option is used. For more details on the daemon, please refer to https://docs.gradle./8.8/userguide/gradle_daemon.html in the Gradle documentation.
...
Error occurred during initialization of VM
Could not reserve enough space for 1572864KB object heap
Environment details:
- OS: Windows
- Java: Installed via Bubblewrap
- Gradle: Version 8.8
- Bubblewrap CLI: Latest version (installed via npm)
Does anyone have suggestions for resolving this issue? Is there something I'm missing?
Any help would be greatly appreciated!
Share Improve this question asked Nov 16, 2024 at 7:58 DeleterDeleter 8101 gold badge12 silver badges33 bronze badges1 Answer
Reset to default 1Ok, here it is a possible solution for bubblewrap that worked for me in this case. It is actually similar to a more generic Gradle heap memory issue which arises because the default Gradle JVM arguments set by Bubblewrap require more memory than your system can allocate (probably some memory leak).
Thus, I added .gradle.jvmargs=-Xmx1024M
to the gradle.properties
file and it solves the problem.
!! However, Bubblewrap overwrites this file during updates and build (bubblewrap update
and bubblewrap build
), which can be frustrating.
To make this change persistent, I automated the process using a js script launched by a npm script with node.
const { execSync } = require('child_process');
const { version } = require('./package.json');
const fs = require('fs');
try {
// run update based on package.json version
execSync(`bubblewrap update --appVersionName=${version} --manifest=twa-manifest.json`, { stdio: 'inherit' });
// replace gradle.properties as said
const gradlePropertiesPath = 'gradle.properties';
let gradleProperties = fs.readFileSync(gradlePropertiesPath, 'utf8');
gradleProperties = gradleProperties.replace('-Xmx1536m', '-Xmx1024M');
fs.writeFileSync(gradlePropertiesPath, gradleProperties);
// run build after it
execSync(`bubblewrap build`, { stdio: 'inherit' });
} catch (error) {
console.error('Failed to run Bubblewrap update and build:', error.message);
process.exit(1);
}