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 ...
随机推荐
- 【模式匹配】Aho-Corasick自动机
1. 多模匹配 AC自动机(Aho-Corasick Automaton)是多模匹配算法的一种.所谓多模匹配,是指在字符串匹配中,模式串有多个.前面所介绍的KMP.BM为单模匹配,即模式串只有一个.假 ...
- vue data对象添加新属性触发视图
<template> <div class="wrap open"> <a>{{test01.name}}</a> <a> ...
- LINQ to SQL语句(2)之Select/Distinct
适用场景:o(∩_∩)o- 查询呗. 说明:和SQL命令中的select作用相似但位置不同,查询表达式中的select及所接子句是放在表达式最后并把子句中的变量也就是结果返回回来:延迟.Select/ ...
- GCC、ARM-LINUX-GCC、ARM-ELF-GCC浅析
一.GCC简介: The GNU Compiler Collection,通常简称GCC,是一套由GNU开发的编译器集,为什么是编辑器集而不是编译器呢?那是因为它不仅支持C语言编译,还支持C++, A ...
- Object C中的数据类型表
类型 例子 NSLog chars char 'a', '\n' %c short int — %hi, %hx, %ho unsigned short int %hu, %hx, %ho ...
- 【C#进阶系列】18 特性Attribute
这个东西有的叫定制特性,然而我喜欢直接叫特性,但是这样的话一些人不知道我说的是什么,如果我说是Attribute的话那么知道的或者用过的就都懂了. 还记得讲到枚举和位标志那一章,关于位标志,有一个[F ...
- Principal Data Scientist
http://stackoverflow.com/jobs/124781/principal-data-scientist-concur-technologies-inc?med=clc&re ...
- 如何改变 FMX ListView 颜色
需求:改变 ListView 颜色 适用:Firemonkey 任何平台 操作:Style 是改变控件外观最便捷的途径,ListView 也不例外,下面示范使用 StyleBook 来设定 ListV ...
- iOS取得AddressBook联系人信息
新建一个CContact类用于存放联系人信息,下面是该类的代码: CContact.h代码: 01 #import <Foundation/Foundation.h> 02 03 ...
- 11.20 CSS定位智博星网页制作
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv=&qu ...