Android Studio Google JAR 文件导致 GC 开销限制超出错误 [英] Android Studio Google JAR file causing GC overhead limit exceeded error

查看:26
本文介绍了Android Studio Google JAR 文件导致 GC 开销限制超出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 OS X 上使用 Android Studio.我收到此错误消息:

I am using Android Studio on OS X. I am getting this error message:

FAILURE:构建失败,出现异常.

FAILURE: Build failed with an exception.

  • 出了什么问题:任务 ':app:preDexDebug' 执行失败.com.android.ide.common.internal.LoggedErrorException:无法运行命令:/Applications/Android Studio.app/sdk/build-tools/android-4.4W/dx --dex --output/Users/alex/AndroidStudioProjects/SilentSMS/app/build/intermediates/pre-dexed/debug/android-4.3_r2.1-f22bbff4d1017230e169a4844a9c2195f13060d2.jar/Users/alex/AndroidStudioProjects/SilentSMS/app/libs/android-4.3_r2.1.jar

  • What went wrong: Execution failed for task ':app:preDexDebug'. com.android.ide.common.internal.LoggedErrorException: Failed to run command: /Applications/Android Studio.app/sdk/build-tools/android-4.4W/dx --dex --output /Users/alex/AndroidStudioProjects/SilentSMS/app/build/intermediates/pre-dexed/debug/android-4.3_r2.1-f22bbff4d1017230e169a4844a9c2195f13060d2.jar /Users/alex/AndroidStudioProjects/SilentSMS/app/libs/android-4.3_r2.1.jar

错误代码:3输出:

  UNEXPECTED TOP-LEVEL ERROR:
  java.lang.OutOfMemoryError: GC overhead limit exceeded
      at com.android.dx.cf.code.RopperMachine.getSources(RopperMachine.java:665)
      at com.android.dx.cf.code.RopperMachine.run(RopperMachine.java:288)
      at com.android.dx.cf.code.Simulator$SimVisitor.visitLocal(Simulator.java:612)
      at com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:412)
      at com.android.dx.cf.code.Simulator.simulate(Simulator.java:94)
      at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:782)
      at com.android.dx.cf.code.Ropper.doit(Ropper.java:737)
      at com.android.dx.cf.code.Ropper.convert(Ropper.java:346)
      at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:282)
      at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:139)
      at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:94)
      at com.android.dx.command.dexer.Main.processClass(Main.java:682)
      at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
      at com.android.dx.command.dexer.Main.access$600(Main.java:78)
      at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
      at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
      at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
      at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
      at com.android.dx.command.dexer.Main.processOne(Main.java:596)
      at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
      at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
      at com.android.dx.command.dexer.Main.run(Main.java:230)
      at com.android.dx.command.dexer.Main.main(Main.java:199)
      at com.android.dx.command.Main.main(Main.java:103)

我正在使用这个库:

http://grepcode.com/snapshot/repository.grepcode.com/java/ext/com.google.android/android/4.3_r2.1/

我提取了 JAR 文件并将其添加到我的项目中 - 我正在尝试构建的项目是:

I pulled the JAR file and added it to my project - the project I am trying to build is:

https://github.com/domi007/silentSMS/

我明白这是因为我的 xms 和 xmx 值太低了.我增加了它们:

I understand it is because my xms and xmx values are too low. I increased them in:

/Applications/Android Studio.app/bin/idea.vmoptions 现在显示:

/Applications/Android Studio.app/bin/idea.vmoptions so that it now says:

-Xms256m
-Xmx1024m

但是,我仍然收到错误消息.这可能是由什么引起的?除了silentSMS 应用程序是一个Eclipse 项目并且我将代码移植到Android Studio 之外,我没有进行任何更改.在 Android Studio 发现错误方面 - 它没有,其他一切看起来都很好.

However, I still get the error. What could this be caused by? Apart from the silentSMS app being an Eclipse project and me porting the code over to Android Studio I haven't changed anything. In terms of Android Studio spotting errors - it doesn't, and everything else looks fine.

推荐答案

我认为有一种单独的方法可以提高 dexing 操作的堆限制.将此添加到 build.gradle 文件中的 android 闭包中:

I think there's a separate way to raise the heap limit of the dexing operation. Add this to your android closure in your build.gradle file:

dexOptions {
    javaMaxHeapSize "4g"
}

看看是否有帮助.

(想法来自 来自 Scott Barta 的这个答案)

这篇关于Android Studio Google JAR 文件导致 GC 开销限制超出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆