当前位置: 首页 > 面试题库 >

Android Studio Google JAR文件导致GC开销限制超出错误

周辰沛
2023-03-14
问题内容

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

失败:生成失败,发生异常。

  • 出了什么问题:任务’: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

错误代码: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文件并将其添加到我的项目中-我要构建的项目是:

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

我了解是因为我的xms和xmx值太低。我增加了它们:

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

-Xms256m
-Xmx1024m

但是,我仍然会收到错误消息。这可能是什么原因造成的?除了silentSMS应用程序是一个Eclipse项目,并且将代码移植到Android Studio之外,我没有做任何更改。关于Android Studio发现错误-不会,其他一切看起来都很好。


问题答案:

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

dexOptions {
    javaMaxHeapSize "4g"
}

看看是否有帮助。



 类似资料:
  • 使用当我尝试构建我的项目时,这种错误越来越多: 错误:任务“:app:CompiledEbugJavaWithJavac”执行失败。OutofMemoryError:超出GC开销限制 有什么办法解决这个问题吗?

  • 我正在尝试预处理一个大的txt文件(10G),并将其存储在二进制文件中以备将来使用。当代码运行时,速度会减慢,并以 异常线程"main"java.lang.OutOfMemoryError: GC开销限制超过 输入文件具有以下结构 这是我正在使用的代码: 基本上,它通过in文件并将数据存储到对象HMbicnt(这是一个哈希映射)。一旦在第二列中遇到新值,它应该将对象写入输出文件,释放内存并继续。

  • 当我执行我的测试时,我得到了这个错误消息: 我知道什么是,但GC开销限制意味着什么?我怎样才能解决这个问题?

  • 我正在IntelliJ Idea Ultimate Edition 2020.2.2上运行Grails 2.5.0。它可以很好地编译和构建代码,但它会不断抛出“java.lang.OutOfMemoryError:超出GC开销限制”错误(整个错误都是复制并粘贴在最后)。以下是我在研究这个错误的基础上尝试的东西: 1)增加构建进程堆大小(在2G、4G和6G下尝试)https://intellij-s

  • 问题内容: 我正在尝试建立一个包含2台服务器的Gridgain集群。 使用 GridDataLoader 将.csv文件中的数据(100万至5000万个数据)加载到Gridgain 。 从加载的数据中找到最小值,最大值,平均值等, 当在Eclipse中作为独立应用程序运行时,我得到正确的输出。 但是,在建立集群(eclipse环境中的2个服务器中的2个节点+我的Eclipse环境中的1个节点)的同

  • 问题内容: 我在一个程序中创建了这个错误,该程序创建了几个(数十万)HashMap对象,每个对象都有几个(15-20)文本条目。这些字符串必须全部收集(不分解成较小的数量),然后再提交给数据库。 根据Sun的说法,该错误发生“如果在垃圾回收上花费了太多时间:如果在垃圾回收上花费了总时间的98%以上,而回收不到2%的堆,则将引发OutOfMemoryError。 ”。 显然,可以使用命令行将参数传递