android基础之依赖注入

来源:互联网 发布:伐木累软件 编辑:程序博客网 时间:2024/06/10 19:35

今天突然在论坛上看到了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中添加:

compile 'org.glassfish:javax.annotation:10.0-b28'




0 0
原创粉丝点击