本文介绍了如何配置匕首的IntelliJ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载的匕首,因为它似乎是在Android的依赖注入一个不错的选择。但我有一些麻烦整合编译器。是否有关于正确设置任何提示?我跟着关于Android的注释中的说明,因为这项目似乎是相似的。但它并不适用于匕首工​​作。

I downloaded dagger as it seems to be a good option for dependency injection in Android. But I have some troubles integrating the compiler. Are there any hints regarding the right settings? I followed the instructions regarding android annotations as this project seems to be similar. But it doesn't work for dagger.

我做了什么:
我加了匕首1.1.0.jar和javax.inject-1.jar到我的项目的lib文件夹,我添加了一个名为编译库包含匕首编译-1.1.0.jar像我这样的新文件夹不想被装在*的.apk文件。

What I did:I added dagger-1.1.0.jar and javax.inject-1.jar to my project's lib folder and I added a new folder called "compile-libs" containing the "dagger-compiler-1.1.0.jar" as I do not want this file to be packed in *.apk.

我添加匕首javax.inject到模块的依赖关系。

I added dagger and javax.inject to the module's dependencies.

现在棘手的问题:我加入了编译器注释编译器设置:

Now the tricky part: I added the compiler to annotation compiler settings:

当我运行程序我得到以下错误:
类de.myproject.app.modules.AndroidModule模块适配器无法加载。请确保code一代为这个模块运行。

When I run the program I get the following error:Module adapter for class de.myproject.app.modules.AndroidModule could not be loaded. Please ensure that code generation was run for this module.

所以,在我看来,code一代未能成行。 Addionally在我的项目生成的文件夹为空。那么,什么是正确的设置,以获得匕首Android项目工作中的IntelliJ?

So it seems to me the code generation did not take place. Addionally the "generated" folder in my project is empty. So what are the correct settings to get dagger to work in Android project in IntelliJ?

推荐答案

没有被发现匕首编译器的依赖关系。

The dagger-compiler dependencies are not being found.

匕首,并javax.inject也是必需的。结果
(对于还需要1.2+番石榴 - )

Dagger, JavaWriter and javax.inject are also required.
(For 1.2+ Guava is also required - guava discussion)

尝试把这些.jar文件在同一文件夹中的匕首,编译器,然后添加的所有4 的也可以作为注解处理器。这适用于Eclipse和应该的IntelliJ了。

Try putting those .jars in the same folder as dagger-compiler and then adding all 4 also as annotation processors. This works for Eclipse and should for IntelliJ too.

或者让1胖罐子所有这些依赖在一起。请参见。

Alternatively make 1 "fat" jar with all those dependencies together. See issue 360 for details.

文件可以从Maven的下载:

Files may be downloaded from Maven:






  • Dagger
  • JavaWriter
  • javax.inject
  • Guava

这篇关于如何配置匕首的IntelliJ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 01:20