【发布时间】:2015-06-10 10:07:17
【问题描述】:
大家好,我想在 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 和应用程序崩溃。
任何建议将不胜感激。提前致谢
【问题讨论】:
标签: android android-studio proguard