现在很多人都使用Android studio开发工具代替eclipse了,当然的 在eclipse使用的好的一些开发框架也会对应的在android studio上面使用。

参考文档:http://blog.csdn.net/u011850815/article/details/42213835

http://blog.csdn.net/hanhailong726188/article/details/40585057

本文就是讲如何在android studio下配置并使用AndroidAnnotations。

闲话不多说,你新建一个项目后,在你的app/目录下有一个build.gradle(称这个为局部gradle).

在此文件中添加下面一些配置:

apply plugin:'android-apt'
def AAVersion='3.0.1'

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    apt "org.androidannotations:androidannotations:$AAVersion"
}

apt {
    arguments {
        androidManifestFile variant.processResources.manifestFile
        resourcePackageName "com.example.org.myapplication(你项目的包名)"
    }
}

在gradle/目录下同样存在一个build.gradle文件(此成为全局gradle),在此文件中添加以下内容:

dependencies {
        classpath 'com.android.tools.build:gradle:0.12.2'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

然后把你manifest文件中的activity名后面加上一个_  注意这个时候android studio会报错。你只需编译一下

点击Refactor下面那个向下的箭头就可以编译成功。

最后你就可以在android studio下面使用AndroidAnnotations框架进行开发咯。具体的AndroidAnnotations使用方法百度一下有很多资料、这里就不详细说明咯。

备注:由于gradle版本越来越高。gradle2.2.1的版本中编译的时候会遇到Could not find property 'processResources' on com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated这个错误,这种错误是由于gradle的版本引起的,在新版本的gradle中的写法为:androidManifestFile variant.outputs[0].processResources.manifestFile

androidManifestFile variant.processResources.manifestFile(老版本写法)

androidManifestFile variant.outputs[0].processResources.manifestFile(新版本写法)
 
import org.androidannotations.annotations.EActivity;

@EActivity(R.layout.activity_main)
public class MainActivity extends Activity { }
 

android studio配置AndroidAnnotations的更多相关文章

  1. Android Studio配置 AndroidAnnotations——Hi_博客 Android App 开发笔记

    以前用Eclicps 用习惯了现在 想学学 用Android Studio 两天的钻研终于 在我电脑上装了一个Android Studio 并完成了AndroidAnnotations 的配置. An ...

  2. Android Studio 配置 androidAnnotations框架详细步骤

    第一步:打开app的build.gradle文件 第二步:添加下面红色的部分 apply plugin: 'com.android.application' android { compileSdkV ...

  3. Win10下Android studio配置

    Win10下Android studio配置 一.安装Android Studio的准备工作 1.下载好JDK,去官网上找一个下载下来 2.安装JDK.并配置环境变量.安装过程:本人将使用的是jdk- ...

  4. Android studio配置Git

    Android studio配置Git 1.下载window 版git并安装:下载地址 2.Android Studio设置git插件:File->Setting->Version Con ...

  5. Android Studio配置Git及Git文件状态说明

    Android Studio配置Git还是比较简单的,麻烦的是可能中间出现各种问题.如果你想了解或感兴趣,请往下看. 首先你得下载Git客户端,网址:http://git-scm.com/downlo ...

  6. Android Studio 配置SVN实现代码管理

    Refference From:http://iaiai.iteye.com/blog/2267346 一.Android Studio配置SVN Android Studio关联配置SVN很简单,在 ...

  7. Android studio 配置JNI环境

    Android studio配置jni开发环境,主要配置是两个build文件,以及新建一个jni文件,放c代码. 代码如下1: apply plugin: 'com.android.model.app ...

  8. Android studio 配置file encoding 无效,中文乱码解决办法

    通过配置Android studio 配置file encoding 无效,中文乱码,问题出现在java编译的时候jack采用了默认编码(中文windows默认的GBK编码)而乱码,所以不管更改bui ...

  9. Android Studio配置使用git

    一.准备 如果没有安装git,那么先要到到Git官网下载git,然后按照提示一步一步安装即可,这个没有什么难度,不过要记得安装的目录. 二.Android Studio配置git File->S ...

随机推荐

  1. object-c [self class] 和 [self _cmd]

    [self class] 返回当前类名 [self _cmd] 返回当前方法名 self 是类的隐藏的参数,指向当前当前调用方法的类 另一个隐藏参数是_cmd,代表当前类方法的selector

  2. CC150 - 11.3

    Question: Given a sorted array of n integers that has been rotated an unknown number of times, write ...

  3. 【BZOJ】2946: [Poi2000]公共串

    http://www.lydsy.com/JudgeOnline/problem.php?id=2946 题意:给n个串,求最大公共子串.(1<=n<=5,每个串长度<=2000) ...

  4. linux网络配置相关命令、虚拟网络接口eth0:0

    网络接口(interface)是网络硬件设备在操作系统中的表示方法,比如网卡在Linux操作系统中用ethX,是由0开始的正整数,比如eth0.eth1...... ethX.而普通猫和ADSL的接口 ...

  5. Java正则表达式教程

    地址:http://www.java3z.com/cwbwebhome/article/article8/Regex/Java.Regex.Tutorial.html#reg0_1

  6. iOS开发项目之一 [ 项目流程]

    项目流程 *人员配置 *客户端(iOS工程师,Android工程师) *前端 h5 *后台人员(php,java,net) *提供接口(请求地址.请求参数,请求方式,接口文档) *UI UE * 效果 ...

  7. salt-ssh使用

    salt-ssh 是 0.17.0 新出现的一个功能,一听这名字就知道它是依赖 ssh 来进行远程命令执行的工具,好处就是你不需要在客户端安装 minion,也不需要安装 master(直接安装 sa ...

  8. [译]- 6-1 排列窗体上的控件(Laying Out Widgets on a Form)

     排列窗体上的控件(Laying Out Widgets on a Form) 中英文对照:form(窗体),layout(布局或者排列,意思是进行窗体上控件的排列的过程,如大小位置等) absolu ...

  9. [转]C#基础回顾:Asp.net 缓存

    本文转自http://www.cnblogs.com/stg609/archive/2009/03/22/1418992.html 缓存的作用      你买电脑的时候,是否会在意CPU的二级缓存?是 ...

  10. MasterPage 变化了的 ClientID ctl00_

    在母版页的服务器端控件 其客户端ID 有时候是多变的 会对javascript jquery的内容获取 造成困扰 比如一个控件: <asp:ContentPlaceHolder ID=" ...