android studio 框架搭建:加入注解框架Annotations

时间:2023-03-08 20:05:42

参考github上的demo,新建一个project后,会有一个位于app文件夹下的局部build.gradle文件和一个位于根目录project下的全局build.gradle文件,我们要修改的是局部gradle文件:

 buildscript {
repositories {
mavenCentral()
}
dependencies {
// replace with the current version of the Android plugin
classpath 'com.android.tools.build:gradle:1.0.0'
// the latest version of the android-apt plugin
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
} repositories {
mavenCentral()
mavenLocal()
} apply plugin: 'com.android.application'
apply plugin: 'android-apt'
def AAVersion = '3.3-SNAPSHOT' // change this to your desired version, for example the latest stable: 3.2 dependencies {
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
} apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
// if you have multiple outputs (when using splits), you may want to have other index than 0 resourcePackageName 'org.androidannotations.gradle' // If you're using Android NBS flavors you should use the following line instead of hard-coded packageName
// resourcePackageName android.defaultConfig.packageName // You can set optional annotation processing options here, like these commented options:
// logLevel 'INFO'
// logFile '/var/log/aa.log'
}
} android {
compileSdkVersion 19
buildToolsVersion "21.1.1" defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
}

最后再在AndroidManifest.xml中的Activity的名字后面加上 _(下划线)

然后编译项目 完成! 如果报错,请多编译几次。编译按钮:

android studio 框架搭建:加入注解框架Annotations

我的顺利编译通过。 参考博客:http://blog.****.net/ljphhj/article/details/37601173