超过了dagger2 GC开销限制 [英] dagger2 GC overhead limit exceeded

查看:168
本文介绍了超过了dagger2 GC开销限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循 TODO 应用程序的 Dagger2 样本,但已纳入OutOfMemoryError:已超出GC开销限制。除此之外,它还有600多个警告:


warning:忽略匿名内部类的InnerClasses属性(org.eclipse.osgi.internal.baseadaptor.BaseStorage $ StateSaver $ 1)不带有关联的EnclosingMethod属性。这个类可能是由一个编译器生成的,它不针对现代的.class文件格式。推荐的解决方案是使用最新的编译器从源代码重新编译类,而不指定任何-target类型选项。忽略此警告的结果是,对这个类的反射操作将错误地指示它不是*内部类。




这是我的代码: dagger2无法找到符号,我得到了我以前的问题在gk5885的帮助下解决。再次感谢你:-)。



刚刚添加 SharedPreferences sharedPreferences() NetComponent 并重建,程序编译了9分钟,并最终抛出该错误。但是,在没有 Dagger2 的情况下编译我的应用程序以前版本的时间是秒,因为我非常确定 Dagger2 导致了此错误。但我不知道为什么以及如何解决这个问题。



我的vm大小:-Xms256m -Xmx1280m。我认为这已经足够了。


任何帮助表示赞赏。



编辑:事实上,在我重建之前,我在apk错误中复制了重复的文件。我通过在gradle中添加它来解决它:

I'm following the Dagger2 sample of TODO app but encounted with OutOfMemoryError: GC overhead limit exceeded. Along with it are 600+ warning likes:

warning: Ignoring InnerClasses attribute for an anonymous inner class (org.eclipse.osgi.internal.baseadaptor.BaseStorage$StateSaver$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.

Here's my code: dagger2 cannot find symbol ,where I got my previous problem solved with help of gk5885. Thanks to you again :-).

Just after I add SharedPreferences sharedPreferences() to NetComponent and rebuild, the program compiles for 9 minutes and end up throwing that error. But the time to compile the previous version of my app without Dagger2 is seconds, on account of which I'm pretty sure Dagger2 caused this error. But I don't know why and how to solve this problem.

And my vm size: -Xms256m -Xmx1280m. I think it's more than enough.

Any help is appreciated.

In fact before I rebuild, I got duplicate file copied in apk error. And I solved it by add this in gradle:

packagingOptions {
        exclude 'META-INF/maven/com.google.guava/guava/pom.properties'
        exclude 'META-INF/maven/com.google.guava/guava/pom.xml'
    } 

也许我应该显示我的依赖关系:

Maybe I should show my dependencies:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'me.yokeyword:indexablestickylistview:0.6.1'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'in.srain.cube:ultra-ptr:1.0.11'
    compile files('libs/ormlite-android-4.49-SNAPSHOT.jar')
    compile files('libs/ormlite-core-4.49-SNAPSHOT.jar')
    compile 'com.jakewharton:butterknife:8.1.0'
    apt 'com.jakewharton:butterknife-compiler:8.0.1'
    compile 'com.google.dagger:dagger:2.2' // dagger2
    compile 'com.google.dagger:dagger-compiler:2.2' // dagger2
    compile project(':ToggleButtonLib')
    compile project(':IMKit')
}

很抱歉有这么多的描述。 ...


Sorry for so many descriptions....

推荐答案

您应该更改

You should change

compile 'com.google.dagger:dagger-compiler:2.2' // dagger2 

apt 'com.google.dagger:dagger-compiler:2.2' // dagger2

因为您目前正在将整个dagger2编译器包含到您的项目中,并且包括番石榴和各种各样的东西。

Because you're currently including the entire dagger2 compiler into your project, and that includes Guava and all kinds of things.

这篇关于超过了dagger2 GC开销限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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