昨天和一个好哥们一起探讨了一下AndroidAnnotations这个框架,发现网上面好多的博客都无法实现,因为在使用AndroidAnnotations需要在android studio上配置环境,很是有些麻烦。
在使用完AndroidAnnotations后,我感觉对eventBus, Butterknife都没有好感了,因为AndroidAnnotations这个框架实在是太好用了,现在就将配置过程放在下面;
实现AndroidAnnotations这个框架,所以新建一个工程,在新建的工程下面,我们进入Project的目录查看方式
大家可以看到上图有两个build。gradle 文件,一个是在app文件夹下,一个是在MyApplication下的build。gradle,那么下面就要在这两个build.gradle下面做文章了,
首先打开MyApplication下的build。gradle我们需要在
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
中插入代码
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
最后效果:
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
//在此处插入gradle配置目前最高是1.8版本,
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
这样MyApplication下的build.gradle文件就配置完了,配置好的MyApplication中的build.gradle完整代码:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
再来配置app下的build.gradle:
打开