標籤:
如今Android Studio的普及,Android開發基本要捨棄Eclipse了,最近使用AndroidAnnotations 註解架構的時候,找了些資料慢慢整出來了,在這給大家簡單分享一下:
首先Gradle裡面配置完全可以根據架構提供的官網學習,Gradle配置官網介紹地址:https://github.com/excilys/androidannotations/wiki/Building-Project-Gradle 在這對其進行簡單的闡述:
分三個點:首先在全域gradle檔案中添加如下資訊
buildscript {
repositories {
jcenter()
mavenCentral() //添加maven中心倉庫
}
dependencies {
classpath ‘com.android.tools.build:gradle:1.3.0‘
classpath ‘com.neenbedankt.gradle.plugins:android-apt:1.4‘ // 添加載入地址
}
}
repositories {
mavenCentral() //添加maven中心倉庫
mavenLocal() //添加本地maven倉庫
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
然後第二步在項目app的gradle中添加如下資訊:
apply plugin: ‘com.android.application‘
apply plugin: ‘android-apt‘ //需要添加
def AAVersion = ‘3.3.2‘ //需要添加,可根據目前的版本自訂其中的版本號碼
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘
}
}
}
dependencies {
compile fileTree(include: [‘*.jar‘], dir: ‘libs‘)
testCompile ‘junit:junit:4.12‘
compile ‘com.android.support:appcompat-v7:23.0.1‘
compile ‘com.android.support:design:23.0.1‘
apt "org.androidannotations:androidannotations:$AAVersion" //需要添加
compile "org.androidannotations:androidannotations-api:$AAVersion" //需要添加
}
apt { //整個內容需要添加
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
}
}
最後構建時如果速度緩慢,需要自備FQ,之後在配置資訊清單檔中對Activity的命名進行改變,在最後面加上一個底線_,如果報錯的話就進行編譯一下就可以了!!!
最後配置就這麼完成了,該架構使用起來確實是很方便的喲~~~
AndroidAnnotations架構配置