那么这是我得到的错误:
Out of memory: Java heap space.
Please assign more memory to Gradle in the project's gradle.properties file.
For example, the following line, in the gradle.properties file, sets the maximum Java heap size to 1,024 MB:
<em>org.gradle.jvmargs=-Xmx1024m</em>
这是因为:
implementation 'nl.bravobit:android-ffmpeg:1.1.7'
当我删除错误消失了。嗯,错误是说将堆大小增加到 1024MB,我确实将它增加到 10GB,它仍然无法工作。这就是有线的。
org.gradle.jvmargs=-Xmx10000m
仍然得到同样的错误。也试过这个:
<application
android:largeHeap="true">
仍然没有机会。请不要建议使用替代库,因为我不能。
最佳答案
在 gradle 5 中,他们大大减少了 default memory要求。
The command line client now starts with 64MB of heap instead of 1GB. This may affect builds running directly inside the client VM using --no-daemon mode. We discourage the use of --no-daemon, but if you must use it, you can increase the available memory using the GRADLE_OPTS environment variable.
The Gradle daemon now starts with 512MB of heap instead of 1GB. Large projects may have to increase this setting using the org.gradle.jvmargs property.
All workers, including compilers and test executors, now start with 512MB of heap. The previous default was 1/4th of physical memory. Large projects may have to increase this setting on the relevant tasks, e.g. JavaCompile or Test.
增加客户端内存
GRADLE_OPTS=-Xmx1g ./gradlew build
增加守护进程内存
./gradlew -D org.gradle.jvmargs=-Xmx1g
更新:
为了进一步说明,gradle 使用客户端 VM、守护进程 VM、工作 VM(并行运行时)以及用于某些任务的附加 VM。
可以使用 GRADLE_OPTS 自定义客户端 VM环境变量。
可以使用 org.gradle.jvmargs 自定义守护程序 VM属性(property)。
工作虚拟机是从守护程序虚拟机派生的,因此将使用相同的设置。
可以通过任务自定义每个任务的虚拟机。对于example
tasks.withType(JavaCompile) { options.compilerArgs += ['-Xdoclint:none', '-Xlint:none', '-nowarn'] }
根据有关客户端 VM 使用的 gradle 文档:
The client VM only handles command line input/output, so it is rare that one would need to change its VM options.
关于android - 连线内存不足 : Java heap space error with ffmpeg library,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56271816/