android基础之依赖注入
2016-05-21 16:40
567 查看
今天突然在论坛上看到了lombok库,于是想用一下,我没有去下载.jar包,而是直接在Android Studio中运用依赖注入:具体的过程如下:
1,在project的build.gradle文件中添加
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' //新添加
}
}
2,在app的build.gradle文件中添加:
apply plugin: 'com.neenbedankt.android-apt'
dependencies中添加:
provided "org.projectlombok:lombok:1.16.8"
apt "org.projectlombok:lombok:1.16.8"
结果运行的时候还出现了如下错误:
Error:(53, 20) 错误: 程序包javax.annotation不存在
这个依旧是注入依赖的问题,解决办法是在dependencies中添加:
1,在project的build.gradle文件中添加
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' //新添加
}
}
2,在app的build.gradle文件中添加:
apply plugin: 'com.neenbedankt.android-apt'
dependencies中添加:
provided "org.projectlombok:lombok:1.16.8"
apt "org.projectlombok:lombok:1.16.8"
结果运行的时候还出现了如下错误:
Error:(53, 20) 错误: 程序包javax.annotation不存在
这个依旧是注入依赖的问题,解决办法是在dependencies中添加:
compile 'org.glassfish:javax.annotation:10.0-b28'
相关文章推荐
- android进程间通信--Binder
- Android深入浅出自定义控件(二)
- Retrofit – Java(Android) 的REST 接口封装类库
- android中各种只读的小文件放置位置
- 【转】android出现注: 某些输入文件使用或覆盖了已过时的 API。 注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。 注: 某些输入文件使用了未经检查或不安全的操作。 注
- Android 窗口机制
- AndroidStudio插件--->推荐与使用
- Android之Window与WindowManager
- android 软键盘弹出隐藏挤压界面等问题
- AndroidStudio中ADBWIFI插件
- Android ViewPager使用详解
- 使用Android studio创建你的第一个项目
- android studio for android learning (四) 兼容性问题
- android高级编程之加载大图片到内存
- Android 利用xml实现各种样式等
- Android开发之Intent.Action
- Android动画的使用点滴
- AndroidStudio配置SVN以及使用代码管理
- Android自定义View之绘制闪动的文字
- [分享]mac如何把本地Android项目提交到github