apply plugin: ' Com.android.application ' android { compilesdkversion 22 buildtoolsversion "22.0.1" defaultConfig { applicationId "Com.change360.helpdoctor" minSdkVersion 14 targetsdkversion 22 versioncode 1 versionName "1.0" } buildtypes { release { minifyEnabled false proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro ' &Nbsp; } }}dependencies { compile filetree ( dir: ' Libs ', include: [' *.jar ']) compile ' Com.android.support: appcompat-v7:22.1.1 ' compile ' com.github.rey5137:material:1.1.0 ' compile ' de.greenrobot:eventbus:2.4.0 ' compile ' net.steamcrafted: load-toast:1.0.6 '}buildscript { repositories { mavencentral () } dependencies { // replace with the current version of the Android plugin classpath ' com.android.tools.build:gradle:1.2.2 ' // the latest version of the android-apt plugin classpath ' com.neenbedankt.gradle.plugins:android-apt:1.4 ' }}repositories { mavencentral () mavenlocal ()}apply plugin: ' android-apt ' def aaversion = ' 3.3.1 ' // change this to your desired version, For example the latest stable: 3.2dependencies { 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 if you ' Re using flavors you should use the following line instead of hard-coded packageName // resourcepackagename android.defaultconfig.packagename // you can set optional annotation processing options here, like these commented options: // logLevel ' INFO ' // logFile '/var/log/aa.log ' }}
Above is the Build.gradle file in Android Studio
Below is the use of activity, is not more refreshing than before.
import android.support.v7.app.actionbaractivity;import android.os.bundle;import android.view.menu;import android.view.menuitem;import android.widget.textview;import Org.androidannotations.annotations.afterviews;import org.androidannotations.annotations.eactivity;import org.androidannotations.annotations.OptionsItem;import org.androidannotations.annotations.optionsmenu;import org.androidannotations.annotations.viewbyid;@ Optionsmenu (R.menu.menu_main) @EActivity (r.layout.activity_main) public class mainactivity extends actionbaractivity { @ViewById TextView textview; @AfterViews public void init () { textview.settext ("Hello world"); } @OptionsItem (r.id.action_settings) void mymethod () { // you can specify the id in the annotation, or use the naming convention }}
Note: At the end of the configuration activity must be added on the original basis _ ( configuration is mainactivity_ instead of mainactivity)
Here is the configuration file
<activity android:name= ". Mainactivity_ "android:label=" @string/app_name "> <intent-filter> <action android:name=" android.i Ntent.action.MAIN "/> <category android:name=" Android.intent.category.LAUNCHER "/> </INTENT-FILTER&G T;</activity>
Androidannotations for use in Android Studio