1

我正在關注Dagger2的示例TODO應用程序,但已包含OutOfMemoryError:已超出GC開銷限制。隨着600+警告喜歡:

警告:忽略InnerClasses屬性爲一個匿名內部類(org.eclipse.osgi.internal.baseadaptor.BaseStorage $ StateSaver $ 1),不帶有關聯的EnclosingMethod屬性。這個類可能是由一個編譯器生成的,它不針對現代的.class文件格式。推薦的解決方案是使用最新的編譯器從源代碼重新編譯類,而不指定任何「-target」類型選項。忽略這個警告的結果是,對這個類的反射操作將錯誤地表明它不是內部類。

這裏是我的代碼:dagger2 cannot find symbol,我在gk5885的幫助下解決了以前的問題。再次感謝你:-)。

在我添加SharedPreferences sharedPreferences()NetComponent並重建之後,程序編譯了9分鐘並最終拋出該錯誤。但編譯我的應用程序的前一個版本的時間沒有Dagger2是秒,因爲我很確定Dagger2導致此錯誤。但我不知道爲什麼以及如何解決這個問題。

而我的VM尺寸:-Xms256m -Xmx1280m。我認爲這已經足夠了。

任何幫助表示讚賞。

編輯:事實上,在我重建之前,我有複製的文件複製在apk錯誤。我解決它在gradle這個補充一點:匕首2超出GC開銷限制

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

也許我應該給我的依存關係:

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') 
} 


對不起,這麼多的描述....

+0

我也碰到過這個。我不記得確切無法保證它會工作,但嘗試文件 - >無效緩存/重啓 – Chisko

+0

@Cheskos它不工作... – Antelope

+0

我認爲你將需要增加你的堆512或1024 – Chisko

回答

1

你應該改變

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

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

因爲您目前正在將整個dagger2編譯器包含到您的項目中,並且包括番石榴和各種各樣的東西。

0

在我的情況下殺死gradle,然後清理項目解決了這個問題。

執行./gradlew --stop然後是./gradlew clean

相關問題