Androidannotations Configuration in Android Studio

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.