2013-10-11 84 views
9

我試圖用Dagger注入一個android註釋活動。AndroidAnnotations和Dagger

java.lang.IllegalArgumentException: No inject registered for members/com.app.server.AddServerActivity_. You must explicitly add it to the 'injects' option in one of your modules.

如果我嘗試添加com.app.server.AddServerActivity_到模塊我得到一個不同勢錯誤

Error: java.lang.ClassCastException: com.sun.tools.javac.code.Attribute$Error cannot be cast to com.sun.tools.javac.code.Attribute$Class 
java.lang.RuntimeException: java.lang.ClassCastException: com.sun.tools.javac.code.Attribute$Error cannot be cast to com.sun.tools.javac.code.Attribute$Class 
    at com.sun.tools.javac.main.Main.compile(Main.java:469) 
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:132) 
    at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:167) 
    at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:364) 
    at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:276) 
    at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:190) 
    at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:162) 
    at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1018) 
    at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:742) 
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:790) 
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:705) 
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:526) 
    at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:314) 
    at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:179) 
    at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:129) 
    at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:220) 
    at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:112) 
    at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:132) 
    at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) 
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:166) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
    at java.lang.Thread.run(Thread.java:722) 
Caused by: java.lang.ClassCastException: com.sun.tools.javac.code.Attribute$Error cannot be cast to com.sun.tools.javac.code.Attribute$Class 
    at com.sun.tools.javac.model.AnnotationProxyMaker$ValueVisitor.visitArray(AnnotationProxyMaker.java:190) 
    at com.sun.tools.javac.code.Attribute$Array.accept(Attribute.java:215) 
    at com.sun.tools.javac.model.AnnotationProxyMaker$ValueVisitor.getValue(AnnotationProxyMaker.java:165) 
    at com.sun.tools.javac.model.AnnotationProxyMaker.generateValue(AnnotationProxyMaker.java:143) 
    at com.sun.tools.javac.model.AnnotationProxyMaker.getAllReflectedValues(AnnotationProxyMaker.java:101) 
    at com.sun.tools.javac.model.AnnotationProxyMaker.generateAnnotation(AnnotationProxyMaker.java:86) 
    at com.sun.tools.javac.model.AnnotationProxyMaker.generateAnnotation(AnnotationProxyMaker.java:78) 
    at com.sun.tools.javac.model.JavacElements.getAnnotation(JavacElements.java:108) 
    at com.sun.tools.javac.model.JavacElements.getAnnotation(JavacElements.java:121) 
    at com.sun.tools.javac.code.Symbol$ClassSymbol.getAnnotation(Symbol.java:888) 
    at dagger.internal.codegen.ValidationProcessor.validateProvides(ValidationProcessor.java:75) 
    at dagger.internal.codegen.ValidationProcessor.process(ValidationProcessor.java:67) 
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793) 
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722) 
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97) 
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029) 
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163) 
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108) 
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824) 
    at com.sun.tools.javac.main.Main.compile(Main.java:439) 
    ... 24 more 

編輯:好的,這似乎是一個已知的問題匕首由生成的類如何交易其他處理器。

https://github.com/square/dagger/issues/322

+1

現在,您可以在最新的AndroidAnnotations SNAPSHOT中使用Dagger,我們將所有註釋複製到生成的類中。 – WonderCsabo

+0

我似乎無法在maven.org或通過谷歌搜索找到最新的快照。你能否指出我能在哪裏獲得快照? – imgen

+1

@imgen [here](https://oss.sonatype.org/content/repositories/snapshots/org/androidannotations/)。但是我們已經發布了具有該複製功能的穩定版本。 – WonderCsabo

回答

0

我建議你使用Dagger2,其使用似乎更 「自然」。

0

這個issue從Dagger的提交709a48b開始是固定的。

合作者cgruber評論2013年11月13日

這兩個地方得到驗證,所以我關閉了這個問題。

不過,使用Dagger2,這是谷歌和廣場的共同努力,似乎是一個好主意。