Android Annotations环境搭建(Android Studio)
来源:互联网 发布:html怎么调用php文件 编辑:程序博客网 时间:2024/05/18 18:53
1.下载Annotations 戳我
2.创建一个新的APP
3.Annontations目录如下:
复制第一个文件夹(AndroidAnnotations)到刚刚创建的项目的lib文件夹下
4.配置文件
在左侧切换至Project的Porject模式,方便我们查看项目的目录
注意右图里的有2个build.gradle文件,一个局部有效,一个全局有效,在局部build.gradle中(加入红色字体)
apply plugin: 'com.android.application'apply plugin: 'android-apt'def AAVersion='3.3.2'android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "com.bq.facecode" minSdkVersion 14 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }}dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' apt "org.androidannotations:androidannotations:$AAVersion" compile "org.androidannotations:androidannotations-api:$AAVersion"}apt { arguments { //老版本的写法2.2.1以前 //androidManifestFile variant.processResources.manifestFile //2.2.1以后 androidManifestFile variant.outputs[0].processResources.manifestFile resourcePackageName 'com.bq.facecode'//项目包名 }}然后在全局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:1.5.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.4' }}allprojects { repositories { jcenter() }}task clean(type: Delete) { delete rootProject.buildDir}
需要注意的地方是,gradle的版本会造成一个错误:
No such property 'processResources' on com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated
遇到这个问题请不要慌张,查看一下全局文件中的红色字体部分,是不是使用的
com.neenbedankt.gradle.plugins:android-apt:1.3,如果是可以改成1.4试试
再查看一下你的gradle的版本,如果版本低于2.2.1,可能你得在局部文件中使用
androidManifestFile variant.processResources.manifestFile //(低版本的写法)
androidManifestFile variant.outputs[0].processResources.manifestFile //(高版本的写法)
关于查看项目Gradle的版本:
在项目左侧文件夹中找到gradle->wrapper->gradle-wrapper.properties,打开后即可看到
#Wed Oct 21 11:34:03 PDT 2015distributionBase=GRADLE_USER_HOMEdistributionPath=wrapper/distszipStoreBase=GRADLE_USER_HOMEzipStorePath=wrapper/distsdistributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip红字那里就是你当前使用的版本
5.最后修改manifest文件
在Activity最后添加一个下划线“—”
6.开始测试~
- Android Annotations环境搭建(Android Studio)
- Android Studio 配置Annotations
- Android Studio配置Annotations
- 【android studio】环境搭建
- Android Studio环境搭建
- Android studio 环境搭建
- Android Studio环境搭建
- Android Studio 环境搭建
- Android studio环境搭建
- android studio环境搭建
- Android Studio 环境搭建
- Android Studio环境搭建
- Android Studio 配置 android annotations
- android studio 框架搭建:加入注解框架Annotations
- 学习android annotations环境搭建及应用总结集锦
- Android Annotations框架第1篇-环境搭建
- android studio 开发环境搭建
- Android studio开发环境搭建
- C++自制Redis数据库(八)基本数据结构--String
- SHUOJ 1553 滑雪问题(大数据)(BFS)
- Android开发学习之路--UI之自定义布局和控件
- 志不强者智不达
- uva 11538 组合
- Android Annotations环境搭建(Android Studio)
- Aireplay-ng的6种攻击模式详解
- ZOJ1061
- Self Summary: Basic concepts of GPU
- xsl-fo图文混排的问题解决
- uva 11401 荣斥
- 1007. Maximum Subsequence Sum (25)
- Android笔记activity的生命周期
- hdoj 2050 折线分割平面