一、配置butterknife

在build.gradle(Module)文件中的dependencies模块添加:

 dependencies {
// add butterknife
compile 'com.jakewharton:butterknife:6.1.0'
}

然后点击右上角Sync Now运行成功后可以在External Libraries中查看到butterknife的jar包。

二、配置Dagger2

1、在build.gradle(Module)文件中的dependencies模块添加:

 dependencies {
// add dagger2
compile 'com.google.dagger:dagger:2.0'
apt 'com.google.dagger:dagger-compiler:2.0'
}

然后点击Sync Now会发现运行失败,这是因为还没有添加android-apt插件的引用。

2、build.gradle(Module)文件顶部添加android-apt插件应用:

apply plugin: 'android-apt'

3、build.gradle(Project)文件的模块添加:

 dependencies {
//add android-apt
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}

然后点击Sync Now运行成功,配置完成。下面给出整个build.gradle文件代码:

build.gradle(Module)文件:

apply plugin: 'com.android.application'
apply plugin: 'android-apt' android {
compileSdkVersion
buildToolsVersion "24.0.1" defaultConfig {
applicationId "com.lz.www.ambts"
minSdkVersion
targetSdkVersion
versionCode
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
} dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0' // add dagger2
compile 'com.google.dagger:dagger:2.0'
apt 'com.google.dagger:dagger-compiler:2.0' // add butterknife
compile 'com.jakewharton:butterknife:6.1.0' }

build.gradle(Project)文件:

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0' //add android-apt
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
} allprojects {
repositories {
jcenter()
}
} task clean(type: Delete) {
delete rootProject.buildDir
}

Android Studio配置Dagger2 以及butterknife的更多相关文章

  1. Win10下Android studio配置

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

  2. Android studio配置Git

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

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

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

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

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

  5. Android studio 配置JNI环境

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

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

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

  7. Android Studio配置使用git

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

  8. android studio配置android开发环境

    1.下载安装android-studio-bundle 地址:https://developer.android.com/sdk/index.html 注意:指定android sdk和android ...

  9. Android Studio配置SVN 以及使用代码管理

    一.Android Studio配置SVN Android Studio关联配置SVN非常easy,在Settings里面.找到Version Control->Subversion.在这个页面 ...

随机推荐

  1. process thread Fiber(linux)

    http://blog.chinaunix.net/uid-21084809-id-2215376.html Processes, kernel threads, user threads, and ...

  2. [Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.5.10

    Every $k\times k$ positive matrix $A=(a_{ij})$ can be realised as a Gram matrix, i.e., vectors $x_j$ ...

  3. Balanced Numbers(数位+状压)

    题意:求给定区间,一个数的数位上每个奇数出现偶数次,每个偶数出现奇数次,这样数的个数 分析:先考虑状态,但总是想不全,所以要把状态压缩一下,用三进制,0 该数不放  1 放了奇数次 2放了偶数次 dp ...

  4. LeetCode题解——ZigZag Conversion

    题目: 把一个字符串按照Z型排列后打印出来,例如 "PAYPALISHIRING" 重新排列后为3行,即 P A H N A P L S I I G Y I R 那么输出为&quo ...

  5. STM32的can现场总线实验心得

    最近在搞stm32实验板的can现场总线实验,之前只是搞过STC51的串口通信,相比之下,发觉can总线都挺复杂的.开始时,知道自己是新手,只知道can总线跟串行通信,485通信,I2C通信一样都是用 ...

  6. OpenStack Swift client开发

    如果你搭建好了Swift环境 ,你应该可以通过Swift 命令 来尝试去测试上传下载等功能,这是因为在安装Swift的时候,通常会安装一个python-swiftclient客户端,这个一个pytho ...

  7. oracle修改process和session数

    第一步:连接服务器,输入sqlplus 第二步:以sysdba身份登陆 第三步:查看和修改processes和sessions参数 1. 查看processes和sessions参数 select * ...

  8. Debug Assertion Failed!

    问题并没有解决..... 不知道怎么回事,先都没有这样的情况... VC++调程序出现如下错误: Debug   Assertion   Failed!       Program:   D:wyuS ...

  9. empty(trim($str))报错原因

    最近写程序的时候发现一个这样的问题,一个if判断如下: [php] if (!empty(trim($ch_url))) { ... } [/php] 执行程序报出如下错误: [code] Fatal ...

  10. Excel中输入√背景显示蓝色,输入×背景显示红色

    实现效果,如下图所示: 步骤:以office2013为例 1.点击"开始->条件格式" 2.点击"突出显示单元格规则->等于" 3.设置对应的规则, ...