Android java.lang.IllegalStateException:模块适配器

Android java.lang.IllegalStateException:模块适配器,android,android-studio,proguard,Android,Android Studio,Proguard,大家好,我想在android中使用ObjectGraph,我正在使用以下内容 applicationGraph = ObjectGraph.create(getModules().toArray()); applicationGraph.inject(this); 但它给我的错误是: java.lang.RuntimeException: Unable to create application com.my.mynews.app.MyApplication: java.lang.Illega

大家好,我想在android中使用ObjectGraph,我正在使用以下内容

applicationGraph = ObjectGraph.create(getModules().toArray());
applicationGraph.inject(this);
但它给我的错误是:

java.lang.RuntimeException: Unable to create application com.my.mynews.app.MyApplication: java.lang.IllegalStateException: Module adapter for class com.my.mynews.b.b could not be loaded. Please ensure that code generation was run for this module.
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4521)
        at android.app.ActivityThread.access$1500(ActivityThread.java:144)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5221)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
 Caused by: java.lang.IllegalStateException: Module adapter for class com.my.mynews.b.b could not be loaded. Please ensure that code generation was run for this module.
        at a.a.j.a(Unknown Source)
        at a.a.j.a(Unknown Source)
        at a.a.x.b(Unknown Source)
        at a.a.i.a(Unknown Source)
        at a.a.z.a(Unknown Source)
我的build.gradle就像:

configurations {
 apt
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.+'
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.jakewharton:butterknife:5.0.+'
compile 'com.jakewharton.timber:timber:2.2.+'
compile 'com.squareup.dagger:dagger:1.2.+'
//provided 'com.squareup.dagger:dagger-compiler:1.2.+'
apt 'com.squareup.dagger:dagger-compiler:1.2.+'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.retrofit:retrofit:1.6.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.+'
compile 'com.fasterxml.jackson.core:jackson-core:2.4.+'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.+'
compile 'com.github.satyan:sugar:1.3'
compile 'com.pnikosis:materialish-progress:1.2'
compile 'com.android.support:cardview-v7:21.0.3'
compile 'com.google.android.gms:play-services-analytics:7.0.0'

compile files('libs/volley.jar')
}
如果我取消上述依赖项中提供的注释并注释apt,并使
minifyEnabled为false
,那么它就可以完美地工作。但是我想减少代码大小,因此我做了
minifyEnabled true
和应用程序崩溃


如有任何建议,将不胜感激。提前谢谢

我自己也遇到了类似的问题。不幸的是,匕首1.2+似乎不能很好地配合proguard的minifyEnabled。因此,我能找到的最佳选择是:

  • 将minifyEnabled设置为false并处理它
  • 升级到Dagger 2.0(这里有一个指南:)
  • 有些人幸运地降级到Dagger 1.0.1,并完全消除了Dagger编译器()