Androidannotations is a very powerful annotation framework, the specific use I do not introduce, we can self-Baidu understand. The configuration in eclipse is also relatively simple, but the configuration in Android Studio seems a bit troublesome, look at the online introduction is not, I went to Google for half a day to find the configuration method, here to share to everyone, my Android The studio version is V1.2.2, and other versions of Android studio have not been tested.
Open our project, switch to project mode, then select the Build.gradle file under the app directory, open it, and add
plugin ' Android-apt ' ' 3.2 '
Buildscript { repositories { mavencentral () } dependencies { ' com.neenbedankt.gradle.plugins:android-apt:1.4 ' }}When you are finished, add the following file at the bottom:
Apt { arguments { androidmanifestfile variant.outputs[0].processresources.manifestfile " Write your own project package name " }}The third step, in Dependencies Dependencies added:
"Org.androidannotations:androidannotations:$aaversion""org.androidannotations: ANDROIDANNOTATIONS-API:$aaversion"
Finally your Build.gradle file is as follows:
<span style= "FONT-SIZE:14PX;" >apply plugin: ' com.android.application ' Apply plugin: ' android-apt ' def aaversion = ' 3.2 ' Buildscript {repositories { Mavencentral ()} dependencies {classpath ' com.neenbedankt.gradle.plugins:android-apt:1.4 '}}andro ID {compilesdkversion buildtoolsversion "22.0.1" defaultconfig {ApplicationID "Com.studio.example.dem O "minsdkversion targetsdkversion versioncode 1 Versionname" 1.0 "} buildtypes { Release {minifyenabled false proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' P Roguard-rules.pro '}}}dependencies {compile filetree (dir: ' Libs ', include: [' *.jar ']) compile ' Com.andro id.support:appcompat-v7:22.2.0 ' apt ' org.androidannotations:androidannotations: $AAVersion "Compile" Org.androidannotations:androidannotations-api: $AAVersion "}apt {arguments {androidmanifestfile variant.outputs[ 0].proceSsresources.manifestfile resourcepackagename "<span style=" font-family: ' Source Code Pro '; >com.studio.example.demo</span> "}}</span><span style=" FONT-SIZE:15PT; " ></span>In the final step, click Build > Make project in the Android Studio menu to compile your project, and at this point you can use the annotation tag in the activity, and note that after we use the callout tag in the class, You also need to add the suffix "_" to the corresponding class in the Androidmainmfest.xml file. For example:
<activity android:name= ". Login_ " android:label=" @string/app_name "> <intent-filter> <action android:name=" Android.intent.action.MAIN "/> <category android:name=" Android.intent.category.LAUNCHER "/> < /intent-filter></activity>
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Androidannotations Configuration in Android Studio