内存不足的错误:在Android工作室Java堆内存 [英] Out of memory error: Java heap memory on Android Studio
问题描述
我如何修复 java.lang.OutOfMemoryError:Java堆空间
编译我的Android项目时
我得到这个后,我升级到Android工作室1版本。但是,我不认为这是问题。最有可能的,当我开始升级我的应用程序的SDK 21(在此之前是SDK 20)。但我不敢肯定无论是。
我GOOGLE了周围的<一个href="http://stackoverflow.com/questions/37335/how-to-deal-with-java-lang-outofmemoryerror-java-heap-space-error-64mb-heap">some <一href="http://javarevisited.blogspot.com/2011/09/javalangoutofmemoryerror-permgen-space.html">fix,但无法找到一个工作。大部分的修复是Eclipse IDE中。
这是在编译时,我得到了充分的logcat错误:
警告:忽略InnerClasses属性匿名内部类
(net.lingala.zip4j.unzip.Unzip $ 1)不来的
相关EnclosingMethod属性。这个类可能是由一个生产
编译器并没有针对现代.class文件格式。推荐
的解决方案是重新编译从源的类,使用最多的最新的编译器
并且不指定任何-target类型选项。忽视的后果
这个警告是在此类反射操作将不正确
表明它是*不*内部类。
警告:忽略InnerClasses属性匿名内部类
(net.lingala.zip4j.unzip.Unzip $ 2)不来的
相关EnclosingMethod属性。这个类可能是由一个生产
编译器并没有针对现代.class文件格式。推荐
的解决方案是重新编译从源的类,使用最多的最新的编译器
并且不指定任何-target类型选项。忽视的后果
这个警告是在此类反射操作将不正确
表明它是*不*内部类。
警告:忽略InnerClasses属性匿名内部类
(net.lingala.zip4j.util.ArchiveMaintainer $ 1)不来的
相关EnclosingMethod属性。这个类可能是由一个生产
编译器并没有针对现代.class文件格式。推荐
的解决方案是重新编译从源的类,使用最多的最新的编译器
并且不指定任何-target类型选项。忽视的后果
这个警告是在此类反射操作将不正确
表明它是*不*内部类。
警告:忽略InnerClasses属性匿名内部类
(net.lingala.zip4j.util.ArchiveMaintainer $ 2)不来的
相关EnclosingMethod属性。这个类可能是由一个生产
编译器并没有针对现代.class文件格式。推荐
的解决方案是重新编译从源的类,使用最多的最新的编译器
并且不指定任何-target类型选项。忽视的后果
这个警告是在此类反射操作将不正确
表明它是*不*内部类。
警告:忽略InnerClasses属性匿名内部类
(net.lingala.zip4j.zip.ZipEngine $ 1)不来的
相关EnclosingMethod属性。这个类可能是由一个生产
编译器并没有针对现代.class文件格式。推荐
的解决方案是重新编译从源的类,使用最多的最新的编译器
并且不指定任何-target类型选项。忽视的后果
这个警告是在此类反射操作将不正确
表明它是*不*内部类。
意外的顶级错误:
java.lang.OutOfMemoryError:Java堆空间
在com.android.dx.rop。code.RegisterSpec $ ForComparison.toRegisterSpec(RegisterSpec.java:642)
在com.android.dx.rop。code.RegisterSpec.intern(RegisterSpec.java:73)
在com.android.dx.rop。code.RegisterSpec.make(RegisterSpec.java:90)
在com.android.dx.cf。code.RopperMachine.run(RopperMachine.java:323)
在com.android.dx.cf。code.Simulator $ SimVisitor.visitLocal(Simulator.java:612)
。在com.android.dx.cf code.Byte codeArray.parseInstruction(字节codeArray.java:412)
在com.android.dx.cf。code.Simulator.simulate(Simulator.java:94)
在com.android.dx.cf。code.Ropper.processBlock(Ropper.java:787)
在com.android.dx.cf。code.Ropper.doit(Ropper.java:742)
在com.android.dx.cf。code.Ropper.convert(Ropper.java:349)
在com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:280)
在com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137)
在com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93)
在com.android.dx.command.dexer.Main.processClass(Main.java:729)
在com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
在com.android.dx.command.dexer.Main.access $ 300(Main.java:82)
在com.android.dx.command.dexer.Main $ 1.processFileBytes(Main.java:602)
在com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
在com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
在com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
在com.android.dx.command.dexer.Main.processOne(Main.java:632)
在com.android.dx.command.dexer.Main.processAllFiles(Main.java:505)
在com.android.dx.command.dexer.Main.runMultiDex(Main.java:332)
在com.android.dx.command.dexer.Main.run(Main.java:243)
在com.android.dx.command.dexer.Main.main(Main.java:214)
在com.android.dx.command.Main.main(Main.java:106)
失败
失败:建立失败,一个例外。
* 什么地方出了错:
执行失败的任务:应用程序:dexDebug。
&GT; com.android.ide.common.internal.LoggedErrorException:无法运行命令:
C:\ Users \用户piracyde25 \ Android的软件开发工具包\集结工具\ 21.1.1 \ dx.bat --dex --no-优化--multi-DEX - 主-DEX-列表C:\ Users \用户piracyde25 \工作区\ Baucar \程序\编译\中间体\多DEX \调试\ maindexlist.txt - 输出C:\ Users \用户piracyde25 \工作区\ Baucar \程序\建立\中间体\ DEX \调试--input-list=C:\Users\piracyde25\workspace\Baucar\app\build\intermediates\tmp\dex\debug\inputList.txt
错误code:
3
输出:
警告:忽略InnerClasses属性匿名内部类
(net.lingala.zip4j.unzip.Unzip $ 1)不来的
相关EnclosingMethod属性。这个类可能是由一个生产
编译器并没有针对现代.class文件格式。推荐
的解决方案是重新编译从源的类,使用最多的最新的编译器
并且不指定任何-target类型选项。忽视的后果
这个警告是在此类反射操作将不正确
表明它是*不*内部类。
警告:忽略InnerClasses属性匿名内部类
(net.lingala.zip4j.unzip.Unzip $ 2)不来的
相关EnclosingMethod属性。这个类可能是由一个生产
编译器并没有针对现代.class文件格式。推荐
的解决方案是重新编译从源的类,使用最多的最新的编译器
并且不指定任何-target类型选项。忽视的后果
这个警告是在此类反射操作将不正确
表明它是*不*内部类。
警告:忽略InnerClasses属性匿名内部类
(net.lingala.zip4j.util.ArchiveMaintainer $ 1)不来的
相关EnclosingMethod属性。这个类可能是由一个生产
编译器并没有针对现代.class文件格式。推荐
的解决方案是重新编译从源的类,使用最多的最新的编译器
并且不指定任何-target类型选项。忽视的后果
这个警告是在此类反射操作将不正确
表明它是*不*内部类。
警告:忽略InnerClasses属性匿名内部类
(net.lingala.zip4j.util.ArchiveMaintainer $ 2)不来的
相关EnclosingMethod属性。这个类可能是由一个生产
编译器并没有针对现代.class文件格式。推荐
的解决方案是重新编译从源的类,使用最多的最新的编译器
并且不指定任何-target类型选项。忽视的后果
这个警告是在此类反射操作将不正确
表明它是*不*内部类。
警告:忽略InnerClasses属性匿名内部类
(net.lingala.zip4j.zip.ZipEngine $ 1)不来的
相关EnclosingMethod属性。这个类可能是由一个生产
编译器并没有针对现代.class文件格式。推荐
的解决方案是重新编译从源的类,使用最多的最新的编译器
并且不指定任何-target类型选项。忽视的后果
这个警告是在此类反射操作将不正确
表明它是*不*内部类。
意外的顶级错误:
java.lang.OutOfMemoryError:Java堆空间
在com.android.dx.rop。code.RegisterSpec $ ForComparison.toRegisterSpec(RegisterSpec.java:642)
在com.android.dx.rop。code.RegisterSpec.intern(RegisterSpec.java:73)
在com.android.dx.rop。code.RegisterSpec.make(RegisterSpec.java:90)
在com.android.dx.cf。code.RopperMachine.run(RopperMachine.java:323)
在com.android.dx.cf。code.Simulator $ SimVisitor.visitLocal(Simulator.java:612)
。在com.android.dx.cf code.Byte codeArray.parseInstruction(字节codeArray.java:412)
在com.android.dx.cf。code.Simulator.simulate(Simulator.java:94)
在com.android.dx.cf。code.Ropper.processBlock(Ropper.java:787)
在com.android.dx.cf。code.Ropper.doit(Ropper.java:742)
在com.android.dx.cf。code.Ropper.convert(Ropper.java:349)
在com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:280)
在com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137)
在com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93)
在com.android.dx.command.dexer.Main.processClass(Main.java:729)
在com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
在com.android.dx.command.dexer.Main.access $ 300(Main.java:82)
在com.android.dx.command.dexer.Main $ 1.processFileBytes(Main.java:602)
在com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
在com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
在com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
在com.android.dx.command.dexer.Main.processOne(Main.java:632)
在com.android.dx.command.dexer.Main.processAllFiles(Main.java:505)
在com.android.dx.command.dexer.Main.runMultiDex(Main.java:332)
在com.android.dx.command.dexer.Main.run(Main.java:243)
在com.android.dx.command.dexer.Main.main(Main.java:214)
在com.android.dx.command.Main.main(Main.java:106)
时,因为一个罐子库我用(zip4j)呢?我曾尝试将其删除,但OOM仍然出现错误。任何想法如何解决这一问题?
编辑:
我还编辑gradlew文件,以增加-Xmx大小。
GRADLE_OPTS =$ GRADLE_OPTS \ - 将Xdock:名称= $ APP_NAME \\ - 将Xdock:图标= $ APP_HOME /媒体/ gradle.icns \\ - Xmx2048M \ -XX:MaxPermSize = 512M \\ - XX:保留codeCacheSize = 512M \
没有什么变化。
编辑2:
也没此修复,但不能帮助它太:
请尝试以下操作:
的Ctrl + Alt + S - >编译器 - >摇篮
在 VM选项
字段写入:
-Xmx2048m -XX:MaxPermSize =512米
我终于通过限制谷歌在摇篮依赖Play服务解决了这个问题。
不过是由谷歌引发的问题Play服务,并通过简单地将其更改为某个特定的库,现在解决了。
com.google.android.gms:玩-服务基地:87年6月5日
How do I fix java.lang.OutOfMemoryError: Java heap space
when compiling my Android project?
I get this after I upgraded to version 1 of Android Studio. But, I don't think this is the problem. Most likely when I start upgrading my app to SDK 21 (before this was SDK 20). But I wasn't so sure either.
I've googled around for some fix, but couldn't find one that works. Most of the fix are for Eclipse IDE.
This is the full logcat error that I get when compiling:
warning: Ignoring InnerClasses attribute for an anonymous inner class
(net.lingala.zip4j.unzip.Unzip$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(net.lingala.zip4j.unzip.Unzip$2) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(net.lingala.zip4j.util.ArchiveMaintainer$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(net.lingala.zip4j.util.ArchiveMaintainer$2) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(net.lingala.zip4j.zip.ZipEngine$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: Java heap space
at com.android.dx.rop.code.RegisterSpec$ForComparison.toRegisterSpec(RegisterSpec.java:642)
at com.android.dx.rop.code.RegisterSpec.intern(RegisterSpec.java:73)
at com.android.dx.rop.code.RegisterSpec.make(RegisterSpec.java:90)
at com.android.dx.cf.code.RopperMachine.run(RopperMachine.java:323)
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:787)
at com.android.dx.cf.code.Ropper.doit(Ropper.java:742)
at com.android.dx.cf.code.Ropper.convert(Ropper.java:349)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:280)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93)
at com.android.dx.command.dexer.Main.processClass(Main.java:729)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:82)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
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:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:505)
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:332)
at com.android.dx.command.dexer.Main.run(Main.java:243)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\piracyde25\android-sdks\build-tools\21.1.1\dx.bat --dex --no-optimize --multi-dex --main-dex-list C:\Users\piracyde25\workspace\Baucar\app\build\intermediates\multi-dex\debug\maindexlist.txt --output C:\Users\piracyde25\workspace\Baucar\app\build\intermediates\dex\debug --input-list=C:\Users\piracyde25\workspace\Baucar\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
3
Output:
warning: Ignoring InnerClasses attribute for an anonymous inner class
(net.lingala.zip4j.unzip.Unzip$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(net.lingala.zip4j.unzip.Unzip$2) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(net.lingala.zip4j.util.ArchiveMaintainer$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(net.lingala.zip4j.util.ArchiveMaintainer$2) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(net.lingala.zip4j.zip.ZipEngine$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: Java heap space
at com.android.dx.rop.code.RegisterSpec$ForComparison.toRegisterSpec(RegisterSpec.java:642)
at com.android.dx.rop.code.RegisterSpec.intern(RegisterSpec.java:73)
at com.android.dx.rop.code.RegisterSpec.make(RegisterSpec.java:90)
at com.android.dx.cf.code.RopperMachine.run(RopperMachine.java:323)
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:787)
at com.android.dx.cf.code.Ropper.doit(Ropper.java:742)
at com.android.dx.cf.code.Ropper.convert(Ropper.java:349)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:280)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93)
at com.android.dx.command.dexer.Main.processClass(Main.java:729)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:82)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
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:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:505)
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:332)
at com.android.dx.command.dexer.Main.run(Main.java:243)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
Is it because of one jar library I used (zip4j)? I did try to remove it, but the OOM error still occurs. Any idea how to fix this?
Edit:
I've also edited gradlew file to increase the -Xmx size.
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\" \"-Xmx2048M \"-XX:MaxPermSize=512M\" \"-XX:ReservedCodeCacheSize=512M\""
Nothing changes.
Edit 2:
Also did this fix but couldn't help it too:
Try the following:
Ctrl + Alt + S -> Compiler -> Gradle
InVM Options
field write:
-Xmx2048m -XX:MaxPermSize=512m
I've finally solved it by limiting the Google Play service in gradle dependency.
The problem however was caused by the Google Play service, and by simply change it to a specific library, it is now solved.
com.google.android.gms:play-services-base:6.5.87
这篇关于内存不足的错误:在Android工作室Java堆内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!