本文主要是介绍AndroidStudio-V1.3.2中配置Annotation详解,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、安装环境的说明
1.下载软件:
AndroidStudio-V1.3.2 下载地址:http://www.android-studio.org/
AndroidAnnotations 下载地址:https://github.com/excilys/androidannotations/wiki/Download
2.注意:在配置过程中我们需要网络的支持,因为它的请求机制为: android-apt;
二、开始进行文件的相关配置
1.首先我们需要新建Android Project,之后我们找到build.gradle(两个)配置文件进行配置。
2.具体配置如下:
在工程目录下的build.gradle的配置,如图所示:
代码如下:
<span style="font-size:14px;">// Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript {repositories {mavenCentral()jcenter()}dependencies {classpath 'com.android.tools.build:gradle:1.3.0'classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'// NOTE: Do not place your application dependencies here; they belong// in the individual module build.gradle files}
}
repositories {mavenCentral()mavenLocal()
}
allprojects {repositories {jcenter()}
}</span>
app目录下 build.gradle 的 配置,如图所示:代码如下:
<span style="font-size:14px;">apply plugin: 'com.android.application'
apply plugin: 'android-apt'
def AAVersion = '3.2'
android {compileSdkVersion 23buildToolsVersion "23.0.1"defaultConfig {applicationId "com.example.administrator.myapplication"minSdkVersion 15targetSdkVersion 23versionCode 1versionName "1.0"}buildTypes {release {minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}}
}dependencies {compile fileTree(dir: 'libs', include: ['*.jar'])compile 'com.android.support:appcompat-v7:23.0.1'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// you should set your package name here if you are using different application IDs// resourcePackageName "your.package.name"// You can set optional annotation processing options here, like these commented options:// logLevel 'INFO'// logFile '/var/log/aa.log'}
}</span>
3.将Annotation的两个androidannotations-3.2.jar和androidannotations-api-3.2.jar包分别导入complie-libs(这个文件夹需要自己手动创建)和libs目录下。
4.配置完成之后,我们点击右上角的sync now进行加载,完成后我们就可以使用注解模式进行开发了。如图所示:
5.对于Annotation的注解命令,下一篇会给大家介绍。
这篇关于AndroidStudio-V1.3.2中配置Annotation详解的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!