eventbus|eventbus 配置

【eventbus|eventbus 配置】 最新推出的3.0版本 加入了 EventBusAnnotationProcessor (注解分析生成索引) 技术,提高了效率
所以3.0版本配置起来 会麻烦一些,如果嫌麻烦的话,可以不用这个注解,但是如果是这样的话,效率会很低,不如用2.4版本
eventbus|eventbus 配置
文章图片



2.4版本很简单 直接添加jar包就行了


3.0版本 添加完jar之后
在Project下的,build.gradle文件中的buildscript 添加 path

buildscript { repositories { jcenter() mavenCentral()} dependencies { classpath 'com.android.tools.build:gradle:2.1.0' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'// NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }



再到app下的 build.gradle中添加如下代码
arguments 里面设置apt 生成的索引的包名和类名
apply plugin: 'com.android.application' apply plugin: 'com.neenbedankt.android-apt'apt { arguments { eventBusIndex "com.demon.testservice.MyEventBusIndex" } }

在 dependencies中 添加
注解这个jar 暂时不知道如何添加 只能apt这样在线添加
compile files('libs/eventbus-3.0.0.jar') apt 'org.greenrobot:eventbus-annotation-processor:3.0.1'



Rebuild Project 之后就能在项目的如下路径中看到 注解生成的 MyEventBusIndex.java
app\build\generated\source\apt\debug\com\demon\testservice

这样3.0版本就配置完毕了

    推荐阅读