android: Invalid maximum heap size: -Xmx16384M
how do i fix This:
C:\Users\USER\WebstormProjects\ngMobile>tns run android
Executing before-prepare hook from C:\Users\USER\WebstormProjects\ngMobile\hooks\before-prepare\nativescript-dev-typescript.js
Found peer TypeScript 2.2.2
Preparing project...
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
What went wrong:
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.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/3.3/userguide/gradle_daemon.html
Please read the following process output to find out more:
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Invalid maximum heap size: -Xmx16384M
The specified size exceeds the maximum representable size.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Starting DaemonProcessing node_modules failed. Error: Command gradlew.bat failed with exit code 1
pakage.json file
{
"description": "NativeScript Application",
"license": "SEE LICENSE IN ",
"readme": "NativeScript Application",
"repository": "",
"nativescript": {
"id": "org.nativescript.AngularMobile",
"tns-android": {
"version": "3.0.0"
}
},
"dependencies": {
"@angular/animations": "~4.1.0",
"@angular/common": "~4.1.0",
"@angular/compiler": "~4.1.0",
"@angular/core": "~4.1.0",
"@angular/forms": "~4.1.0",
"@angular/http": "~4.1.0",
"@angular/platform-browser": "~4.1.0",
"@angular/router": "~4.1.0",
"nativescript-angular": "~3.0.0",
"nativescript-theme-core": "~1.0.2",
"reflect-metadata": "~0.1.8",
"rxjs": "~5.3.0",
"tns-core-modules": "~3.0.0",
"zone.js": "~0.8.2"
},
"devDependencies": {
"babel-traverse": "6.4.5",
"babel-types": "6.4.5",
"babylon": "6.4.5",
"lazy": "1.0.11",
"nativescript-dev-typescript": "~0.4.0",
"typescript": "~2.2.1"
}
}
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (5 by maintainers)
Commits related to this issue
- android studio integration folder structure — committed to NativeScript/android by Plamen5kov 7 years ago
I had the same problem with “gradle” and “tns run” in my Windows machine and it was solved changing JAVA_HOME environment variable to x64 version path.
JAVA_HOME = C:\Program Files\Java\jdk1.8.0_181
Regards
for 32 bit computers just change org.gradle.jvmargs=-Xmx2048M to org.gradle.jvmargs=-Xmx256M. This will let the CLI to create java virtual machine.
Go to platforms/android/gradle.properties and them change the org.gradle.jvmargs Thank you 😃
@alfredobialo it would appear that we’ve set the maximum heap size for the gradle process too big and didn’t foresee the scenario where developers would use a 32bit Java.
If it’s possible, please remove the current JDK distribution, then download and install the 64bit 1.8 JDK - http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html. Running your tns project afterwards should be straightforward.
If upgrading to a 64bit distribution of the Java SE Development Kit is not an option however, then you need to open
platforms/android/gradle.propertiesin a text editor and edit theorg.gradle.jvmargsproperty toorg.gradle.jvmargs=-Xmx2048MPlease fill out the issue template when logging issues in the future. Thank you!
Even if its a 64bit JVM, 16384M is a massive value, Android Studio sets the default at Xmx1536m so if you change it to that it should work