LoginSignup
8
5

More than 5 years have passed since last update.

Androidビルドで「You build has exceeded the memory limit of 4G on 1 container. 」の対処法

Posted at

みなさんこんにちわ。
僕は、最近まで「Nginx」のこと、

nginx.jpg

って言ってたんですけど、これ正しくないです。
えんじんえっくす」っていうのが正しいみたいなのですけど、これ無理すぎないですか?

  • IIS => あいあいえす(わかる)
  • Apatch => あぱっち(わかる)
  • Nginx => えんじんえっくす(ワカンネ)

どうも納得できないですよね。
言葉の由来とかもよくわかんないですけど、みんなコレちゃんと読めてるんですかね?!
Nginx(ぬぎんくす)っていうのが正しい気がしてて、僕が会社のエラい人だったら「Nginx(えんじんえっくす)」っていう人がいたら絶対即クビにしてますね。

Circle CIのメモリの使用量は4Gまでであり、越えるとエラーで止まる。

僕は会社のエラい人でもなんでもないので、別に誰もクビにならなくてよかったなと思いますけど、そんな僕がSlackのCircleCIチャンネルでAndroidビルドが連続して失敗を確認しましたよ。

ビルドエラーを確認すると下記のようなエラーメッセージが表示されていました。

./gradlew clean assembleDebug -PpreDexEnable=false died unexpectedly

Building 88%90% > :app:preDexDebugAction failed: ./gradlew clean assembleDebug -PpreDexEnable=false

そしてcircle CIのビルドジョブの上の方に下記メッセージが表示されてました。

You build has exceeded the memory limit of 4G on 1 container. The results of this build are likely invalid. We have taken a snapshot of the memory usage at the time, which you can find in a build artifact named memory-usage.txt. The RSS column in this file shows the amount of memory used by each process, measured in kilobytes.

つまり1コンテナのメモリ使用量は4Gまでなので、お前超えてるからコケたよってことのようです。

(解決策)省メモリビルドのために、いろいろパラメータをつければOK!

下記のように省メモリでビルドするようにすれば通りました。

circle.yml
deployment:
    master:
        branch: master
        commands:
            - ./gradlew assembleDebug -PpreDexEnable=false -Pcom.android.build.threadPoolSize=1 -Dorg.gradle.parallel=false -Dorg.gradle.jvmargs="-Xms512m -Xmx512m" -Dorg.gradle.daemon=false

それではまたどこかでお会いしましょう!

参考

Gradle assembleDebug and preDexDebug fail with CircleCI

8
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
5