天天看点

IntelliJ IDEA下配置AndroidAnnotations

发现如何IntelliJ IDEA下配置AndroidAnnotations国内没有任何教程,感觉有必要分享一下自己遇到的问题并如何解决。希望有助于大家~

1、安装Intellij IDEA,这个不是我要说的重点,官网都有。

2、新建一个Android工程。

3、下载AndroidAnnotations library。解压后会有androidannotations-api-2.7.1.jar 和androidannotations-2.7.1.jar 把后者放到工程下compile-libs文件夹,没有的话新建改名.

4、修改工程的依赖包选项,导入API包。如下图所示

IntelliJ IDEA下配置AndroidAnnotations

5、File -> Settings -> Compiler -> Annotation Processors. 设置成如下图所示,这里我要说明几点首先设好Path指向you_project_path\compile-libs\androidannotations-2.7.1.jar !!!

其次store generated sources relative to选择后者

IntelliJ IDEA下配置AndroidAnnotations

6、设置Run Configurations属性如下图所示,别忘了把AndroidMainfest.xml里的activitie name 一并改了:

IntelliJ IDEA下配置AndroidAnnotations

7、设置生成文件夹 Project Structure -> Modules -> Sources tab -> right click on generated folder -> Sources.如下图:

IntelliJ IDEA下配置AndroidAnnotations

7、重新编译,类似Eclipse的clean功能,Build -> Rebuild Project 然后运行看下效果! 

最后代码中使用AndroidAnnotations library 后跳转时必须如下写 ActivityName + _ suffix. 像:

startActivity(this, MyListActivity_.class);