Support for setting `org.gradle.jvmargs` property in gradle.properties
complete
P
Philip Lindberg
When running e2e tests with detox on android, I've found that I often encounter the following error:
Execution failed for task ':expo-application:packageDebugAndroidTest'.
> A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
> java.lang.OutOfMemoryError (no error message)
This happens specifically after running
detox build -c android
(after first running expo prebuild
on a managed project). A workaround I've found involves tweaking the android memory settings in the project gradle file (android/gradle.properties). Changing the
org.gradle.jvmargs
property from -Xmx2048m
to -Xmx4096m
seems to do the trick.However, the problem with tweaking
gradle.properties
directly is it'll get regenerated every time expo prebuild --clean
is run. So, are there any plans to support making these types of tweaks via maybe a config plugin? I know expo-build-properties
allows you to tweak some android build properties like compileSdkVersion
and minSdkVersion
, but it doesn't seem to support tweaking other properties like org.gradle.jvmargs
.P
Philip Lindberg
Brent Vatne: that did it, thanks!
In case anyone else runs into the same problem, this is what I ended up with for my config plugin (
./plugins/withGradleProperties.js
):const { withGradleProperties } = require('@expo/config-plugins')
module.exports = (config, options) => {
return withGradleProperties(config, (config) => {
for (const item of config.modResults) {
if (item.key in options) {
item.value = options[item.key]
}
}
return config
})
}
And in my
app.config.ts
:export default ({ config }: ConfigContext): ExpoConfig => ({
...config,
plugins: [
[
'./plugins/withGradleProperties',
{
'org.gradle.jvmargs': '-Xmx4096m -XX:MaxMetaspaceSize=512m',
},
],
],
})
Wodin
FYI, by doing the following search:
I found what I think you're looking for:
Some of the other search results might also be worth a look
Brent Vatne
complete
use the
withGradleProperties
mod in a config plugin to customize it: https://docs.expo.dev/guides/config-plugins/P
Philip Lindberg
Brent Vatne: that did it, thanks!
In case anyone else runs into the same problem, this is what I ended up with for my config plugin (
./plugins/withGradleProperties.js
):const { withGradleProperties } = require('@expo/config-plugins')
module.exports = (config, options) => {
return withGradleProperties(config, (config) => {
for (const item of config.modResults) {
if (item.key in options) {
item.value = options[item.key]
}
}
return config
})
}
And in my
app.config.ts
:export default ({ config }: ConfigContext): ExpoConfig => ({
...config,
plugins: [
[
'./plugins/withGradleProperties',
{
'org.gradle.jvmargs': '-Xmx4096m -XX:MaxMetaspaceSize=512m',
},
],
],
})