android studio 框架搭建:加入注解框架Annotations
16lz
2021-01-26
参考github上的demo,新建一个project后,会有一个位于app文件夹下的局部build.gradle文件和一个位于根目录project下的全局build.gradle文件,我们要修改的是局部gradle文件:
1 buildscript { 2 repositories { 3 mavenCentral() 4 } 5 dependencies { 6 // replace with the current version of the Android plugin 7 classpath 'com.android.tools.build:gradle:1.0.0' 8 // the latest version of the android-apt plugin 9 classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'10 }11 }12 13 repositories {14 mavenCentral()15 mavenLocal()16 }17 18 apply plugin: 'com.android.application'19 apply plugin: 'android-apt'20 def AAVersion = '3.3-SNAPSHOT' // change this to your desired version, for example the latest stable: 3.221 22 dependencies {23 apt "org.androidannotations:androidannotations:$AAVersion"24 compile "org.androidannotations:androidannotations-api:$AAVersion"25 }26 27 apt {28 arguments {29 androidManifestFile variant.outputs[0].processResources.manifestFile30 // if you have multiple outputs (when using splits), you may want to have other index than 031 32 resourcePackageName 'org.androidannotations.gradle'33 34 // If you're using Android NBS flavors you should use the following line instead of hard-coded packageName35 // resourcePackageName android.defaultConfig.packageName36 37 // You can set optional annotation processing options here, like these commented options:38 // logLevel 'INFO'39 // logFile '/var/log/aa.log'40 }41 }42 43 android {44 compileSdkVersion 1945 buildToolsVersion "21.1.1"46 47 defaultConfig {48 minSdkVersion 949 targetSdkVersion 1950 }51 }
最后再在AndroidManifest.xml中的Activity的名字后面加上 _(下划线)
然后编译项目 完成! 如果报错,请多编译几次。编译按钮:
我的顺利编译通过。 参考博客:http://blog.csdn.net/ljphhj/article/details/37601173
更多相关文章
- Android多个React-Native模块的实现及源码解读
- android之动态新建txt文件与读取
- android学习记录2(日志、上下文、android下数据存储、xml基础)
- android mk file 描述
- android studio导出apk步骤
- Android(安卓)Bugly 热修复 快速接入
- 新浪微博2.5.1 for Android(安卓)去广告
- Android-telephony各文件解释
- --Android引用so文件引发的血案