Android アプリ開発「MATRIX」

Androidアプリの開発に役立つサンプル集

ヒープサイズエラーが出た時の対処方法

ヒープサイズエラーが出た時の対処方法

開発する端末を変えると、下記のような「ヒープサイズ(heep size)」に関係するエラーが出てしまい開発ができなくなってしまう場合があります。(例:デスクトップで作り始めたアプリをノートPCで持ち出して開発する場合など)

<ヒープサイズエラー例> 

Error:Unable to start the daemon process: could not reserve enough space for object heap. 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:
org.gradle.jvmargs=-Xmx1024m
Read Gradle's configuration guide
Read about Java's heap size

 

もしこの手のエラーが出た時には、赤色の部分のコードを「gradle.properties」ファイルの最後に追加してあげると解決する場合があります。「gradle.properties」ファイルは画面左にあるプロジェクトエクスプローラーの中に存在します。

<gradle.properties>

# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

org.gradle.jvmargs=-Xmx1024m ←追加

以上、ぜひ試してみてください。 

END