Android Annotations 4.0.0 配置Rest API

来源:互联网 发布:知乎中国出口构成 编辑:程序博客网 时间:2024/05/23 14:20

AndroidAnnotations 从4.0.0开始模块化了,rest-api作为单独的模块发行。在下面的介绍中有增加一个android annotations模块的方法。
https://github.com/excilys/androidannotations/wiki/Building-Project-Gradle#adding-more-aa-plugins
下面我只说下我的配置:
在项目的build.gradle文件中添加依赖

apt "org.androidannotations:androidannotations:$AAVersion"compile "org.androidannotations:androidannotations-api:$AAVersion"apt "org.androidannotations:rest-spring:$AAVersion"compile "org.androidannotations:rest-spring-api:$AAVersion"provided 'org.springframework.android:spring-android-rest-template:2.0.0.M3'

需要依赖Spring For Android。依赖的时候如果用compile,会提示重复引用了Jar包,不加的话,需要的类Android Studio都不提示。所以改成provided了。
需要注意的是,需要在项目的build.gradle和app的build.gralde里同时添加

maven {    url = 'https://oss.sonatype.org/content/repositories/snapshots'}

开始只在项目的build.gralde里添加的,一直编译不了。后来在app的build.gradle也加上就编译通过了。

1 0
原创粉丝点击