AndroidAnnotations配置--Android studio
1.引入对android-apt的依赖。在全局build.gradle中文件中添加以下代码。(Project目录下的build.gradle)
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2+'
}
}
2.设置android-apt参数 。注意把包名换成你的应用的。另外outputs[0]是在新的android-studio的版本中才需要加的。(Module目录下的build.gradle)
apply plugin: 'android-apt' //添加android-apt插件
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
//androidManifestFile variant.processResources.manifestFile(老版本写法)
resourcePackageName "你的包名"
}
}
3.使用apt引入对androidannotation的依赖。(Module目录下的build.gradle)
dependencies {
apt 'org.androidannotations:androidannotations:3.2'
compile 'org.androidannotations:androidannotations-api:3.2' }
4.最后的build文件应该是这样的。
// Project目录下的build.gradle buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2+'
}
} //Module目录下的build.gradle apply plugin: 'com.android.application'
apply plugin: 'android-apt' android {
compileSdkVersion 21
buildToolsVersion 21.1.2 defaultConfig {
applicationId com.tanglikang.annotationtest
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName 1.0
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
} apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
resourcePackageName com.tanglikang.annotationtest
}
} dependencies {
apt org.androidannotations:androidannotations:3.0+ // add these
compile org.androidannotations:androidannotations-api:3.0+ // two lines
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
5.重新build工程,系统会自动下载依赖的第三方库。然后就可以使用AndroidAnnotation了。
注:如果出现下列错误,请将dependencies中的“compile fileTree(dir: 'libs', include: ['*.jar'])”删除。
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lorg/androidannotations/annotations/AfterExtras;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:)
at com.android.dx.command.dexer.Main.run(Main.java:)
at com.android.dx.command.dexer.Main.main(Main.java:)
at com.android.dx.command.Main.main(Main.java:)
AndroidAnnotations配置--Android studio的更多相关文章
- Ubuntu环境下配置Android Studio【转】
本文转载自:https://www.jianshu.com/p/1f6295f9c955 之前学习Android开发的时候,一直跟各种教程一样,使用的是Eclipse+ADT,主要是比较方便,容易上手 ...
- 安装并配置 Android Studio 开发工具和 Genymotion 模拟器
需求说明: 安装并配置 Android Studio 开发工具和 Genymotion 模拟器. 熟练使用 Genymotion 模拟器,掌握 Genymotion 模拟器的基本设置和程序安装. 实现 ...
- 0.[WP Developer体验Andriod开发]之从零安装配置Android Studio并编写第一个Android App
0. 所需的安装文件 笔者做了几年WP,近来对Android有点兴趣,尝试一下Android开发,废话不多说,直接进入主题,先安装开发环境,笔者的系统环境为windows8.1&x64. 安装 ...
- 0.[Andriod]之从零安装配置Android Studio并编写第一个Android App
0. 所需的安装文件 笔者做了几年WP,近来对Android有点兴趣,尝试一下Android开发,废话不多说,直接进入主题,先安装开发环境,笔者的系统环境为windows8.1&x64. 安装 ...
- 篇一、安装配置Android Studio
系统:Mac 10.10 Java JDK:官方JDK1.8 IDE:Android Studio 1.2 Android SDK:24.2 模拟器:genymtion 安装 Mac版本的Androi ...
- [Android] 环境优化配置Android Studio发展NDK
======================================================== 作者:qiujuer 博客:blog.csdn.net/qiujuer 站点:www. ...
- 安装Android Studio (一)同时配置Android Studio环境变量
安装Android Studio 安装android 一直next就行了.这以步需要10分钟左右. 我的安卓SDK在这个目录 C:\Users\user\AppData\Local\Android\s ...
- 配置Android Studio
1.去gradle官网下载gradle,gradle的版本可以在C:\Program Files\Android\Android Studio\gradle下看到 2.新建一个项目,退出后把下载好的g ...
- ubuntu14.04 配置android studio环境
二.复制所需的文件到ubuntu 2.1.如果你还没有linux版本的android studio.sdk.jdk请先下载所需文件,我已经上传到百度网盘了 下载地址: android studio-l ...
随机推荐
- JAVA 设计模式 迭代器模式
用途 迭代器模式 (Iterator) 提供一种方法顺序访问一个聚合对象中各个元素,而又不暴露该对象的内部表示. 迭代器模式是一种行为型模式. 结构
- SQL Server时间粒度系列----第2节日期、周时间粒度详解
本文目录列表: 1.从MySQL提供的TO_DAYS和FROM_DAYS这对函数说起2.SQL Server日期时间粒度3.SQL Server周有关时间粒度 4.总结语 5.参考清单列表 从My ...
- SQL Server数字辅助表的实现
数字辅助表是一个连续整数的数列,通常用来实现多种不同的查询任务.大多分两类:足够大物理数字表和表函数,前者可以称为静态的,后者可以称为动态且按需生产. 物理数字表 物理数字表通常存在一 ...
- ES6笔记(3)-- 解构赋值
系列文章 -- ES6笔记系列 解构赋值,即对某种结构进行解析,然后将解析出来的值赋值给相关的变量,常见的有数组.对象.字符串的解构赋值等 一.数组的解构赋值 function ids() { ret ...
- Winform防止程序重复运行
需求:1.点击“关闭”按钮时,程序最小化到托盘,并没有退出,这时再次运行程序,不会重复运行,而是显示已运行的程序:2.支持不同目录:3.支持修改名称. 代码(不支持修改名称,不支持不同目录): usi ...
- go语言 hello 小结
在编译go语言的时候: 写了一段这样的代码 package main import "fmt" func main() { fmt.Println("Hello, ...
- DevExpress winform XtraEditor常用控件
最近在公司里面开始使用DevExpress winform的第三方控件进行开发和维护,这里整理一些常用控件的资料以便于后续查看 ComboBoxEdit 这个控件和winform自带的控件差不多,使用 ...
- Asp.Net WebService 使用后来管理系统对接口方法进行公开控制
思路: 1.需要找一个访问Webservice的统一入口,刚开始进入了一个误区,以为WebService是单独的运行程序,后来经朋友提醒,其实它也是通过http请求在asp.net framework ...
- C++: read access data using ADOX.DLL and System::Data::OleDb
#pragma once #include "Form2.h" namespace cdemo { using namespace System; using namespace ...
- 【Java每日一题】20161130
20161129问题解析请点击今日问题下方的"[Java每日一题]20161130"查看 package Nov2016; public class Ques1130 { publ ...