Android Studio配置Dagger2 以及butterknife
一、配置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的更多相关文章
- Win10下Android studio配置
Win10下Android studio配置 一.安装Android Studio的准备工作 1.下载好JDK,去官网上找一个下载下来 2.安装JDK.并配置环境变量.安装过程:本人将使用的是jdk- ...
- Android studio配置Git
Android studio配置Git 1.下载window 版git并安装:下载地址 2.Android Studio设置git插件:File->Setting->Version Con ...
- Android Studio配置Git及Git文件状态说明
Android Studio配置Git还是比较简单的,麻烦的是可能中间出现各种问题.如果你想了解或感兴趣,请往下看. 首先你得下载Git客户端,网址:http://git-scm.com/downlo ...
- Android Studio 配置SVN实现代码管理
Refference From:http://iaiai.iteye.com/blog/2267346 一.Android Studio配置SVN Android Studio关联配置SVN很简单,在 ...
- Android studio 配置JNI环境
Android studio配置jni开发环境,主要配置是两个build文件,以及新建一个jni文件,放c代码. 代码如下1: apply plugin: 'com.android.model.app ...
- Android studio 配置file encoding 无效,中文乱码解决办法
通过配置Android studio 配置file encoding 无效,中文乱码,问题出现在java编译的时候jack采用了默认编码(中文windows默认的GBK编码)而乱码,所以不管更改bui ...
- Android Studio配置使用git
一.准备 如果没有安装git,那么先要到到Git官网下载git,然后按照提示一步一步安装即可,这个没有什么难度,不过要记得安装的目录. 二.Android Studio配置git File->S ...
- android studio配置android开发环境
1.下载安装android-studio-bundle 地址:https://developer.android.com/sdk/index.html 注意:指定android sdk和android ...
- Android Studio配置SVN 以及使用代码管理
一.Android Studio配置SVN Android Studio关联配置SVN非常easy,在Settings里面.找到Version Control->Subversion.在这个页面 ...
随机推荐
- CSS 盒子模型(Box model)中的 padding 与 margin
本文将讲述 HTML 和 CSS 的关键—盒子模型 (Box model) .理解 Box model 的关键便是 margin 和 padding 属性,而正确理解这两个属性也是学习用 CSS 布局 ...
- TPL
namespace TPLTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); } pr ...
- Clone PDB from same CDB
Clone PDB 用途: 1.用于测试,从生产系统clone数据来进行测试 2.诊断性能问题 Clone PDB Using OMF from same CDB 环境信息: DB Version ...
- C++ ODR规则与dlopen 问题
问题: 开发平台*.so插件的时候遇到相同的函数名称出现在不同的.so文件中,假设分别为a.so和b.so,b.so要使用a.so中的定义函数 a(),而在dlopen会先加载a.so然后加载b.so ...
- 【原】Redis-LRU缓存
Redis高级篇 Redis-LRU缓存 将Redis作为缓存使用时,有时添加新数据时,旧数据是很难被清空的. LRU(Least Recently Used) 近期最少使用算法是常用算法之一. 最大 ...
- 使用weka进行Cross-validation实验
Generating cross-validation folds (Java approach) 文献: http://weka.wikispaces.com/Generating+cross-va ...
- 取得Resultset的记录条数
public Boolean exists(String sql) { try { stm = conn.createStatement( java.sql.ResultSet.TYPE_SCROLL ...
- IOS成长之路-调用照相机和相册功能
打开相机: //先设定sourceType为相机,然后判断相机是否可用(ipod)没相机,不可用将sourceType设定为相片库 UIImagePickerControllerSourceType ...
- A Tour of Go Advanced Exercise: Complex cube roots
Let's explore Go's built-in support for complex numbers via the complex64 and complex128 types. For ...
- Extjs4---Cannot read property 'addCls' of null
用MVC做后台管理系统时遇到的问题,关于tab关闭后再打开不显示,或者报错 我在新的tabpanel中加入了一个grid,当我关闭再次打开就会报错Cannot read property 'addCl ...