java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread.
最近在学习RxJava 感觉很happy ,happy的同时遇到不少问题 没办法一点一点来 上张帅图先

在使用RxJava + Retrofit 的时候 有时候接口请求参数不规范
比如 {}
@FormUrlEncoded
@POST("get_info")
Observable<String> getInfo(@Field("{}") String json); 但是怎么既能够返回
new BaseSubscribe<String>()
有能够返回
new BaseSubscribe<实体类呢?>() 查到
ScalarsConverterFactory scalarsConverterFactory = ScalarsConverterFactory.create();
.addConverterFactory(scalarsConverterFactory)来增加字符串请求 使用
GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create();
.addConverterFactory(gsonConverterFactory)增加实体类请求 但是 我这样做了却不行
后来查到 要这样才行==
可能是版本问题吧。。
GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(new Gson()); ScalarsConverterFactory scalarsConverterFactory = ScalarsConverterFactory.create();
.baseUrl(ConstantApi.baseUrl)
.addConverterFactory(scalarsConverterFactory)
.addConverterFactory(gsonConverterFactory)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build(); 别忘了:
//RxJava与Retrofit的适配器
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.squareup.retrofit2:converter-scalars:2.1.0' 参考 :http://www.th7.cn/Program/Android/201605/851109.shtml
http://www.jianshu.com/p/dbc46cc033fb
感谢作者 最后截个图看一下目前的代码结构 很酸爽有木有。。。

另外关于新手使用RxJava需要注意的:
subscriptions = new CompositeSubscription();
new CompositeSubscription();来添加 每次请求返回的Subscription对象 记得在BaseActivity中subscription.unsubscribe();
参考:http://blog.chengyunfeng.com/?p=1010感谢 原作者原文中还有很多值得研究学习的东西
java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread.的更多相关文章
- Exception thrown on Scheduler.Worker thread. Add `onError` handling
<html> <head></head> <body> java.lang.IllegalStateException: Exception throw ...
- 严重: Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutputStream() has already been called
错误: 严重: Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutput ...
- 严重: Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutputStream() has already been called for this response
严重: Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutputS ...
- nested exception is java.lang.IllegalStateException: Cannot forward after response has been committed
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is ...
- nested exception is java.lang.IllegalStateException: Context namespace element 'annotation-config' a
公司还用的是spring低版本,今天用jre 8测试了一下,发现错误: Unexpected exception parsing XML document from class path resour ...
- Exception in thread "main" java.lang.IllegalStateException: Failed to read 问题解决
开发中偶尔遇到这样的问题:Exception in thread "main" java.lang.IllegalStateException: Failed to read .. ...
- Springboot 上传报错: Failed to parse multipart servlet request; nested exception is java.lang.IllegalStateException: The multi-part request contained parameter data (excluding uploaded files) that exceede
Failed to parse multipart servlet request; nested exception is java.lang.IllegalStateException: The ...
- 异常-User class threw exception: java.lang.IllegalStateException: Cannot call methods on a stopped SparkContext.
1 详细信息 User class threw exception: java.lang.IllegalStateException: Cannot call methods on a stopped ...
- SpringBoot整合Elasticsearch启动报错处理 nested exception is java.lang.IllegalStateException: availableProcessors is already set to [8], rejecting [8]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean wit ...
随机推荐
- Linux C 程序 空语句-gcc编译命令(SIX)
C语言语句1.空语句:当一个if或者while判断部分能完成工作,空语句可以用来表示if或者while内的空循环体 if(a == b ); 2.gcc编译器 //程序的编译过程: // 预处理:pr ...
- javascript之变量、作用域、作用域链
一.变量 javascript的变量是松散类型的,所谓松散类型就是说定义的变量可以用来保存任何类型的数据.定义变量时要使用var操作符后面跟变量名.这里的var是一个关键字,如果定义变量时省略了var ...
- animation css3动画与CSS3 @keyframes担配使用创建往复平缓动画
通过 @keyframes 规则,您能够创建动画. 创建动画的原理是,将一套 CSS 样式逐渐变化为另一套样式. 在动画过程中,您能够多次改变这套 CSS 样式. 以百分比来规定改变发生的时间,或者通 ...
- stop() 是用于停止动画 :animated 用于判断动画是否在进行中
stop() 是用于停止动画 if($("element").is(":animated")) 用于判断动画是否在进行中
- CSS3 animation-fill-mode 属性
现在专注于移动端开发项目,对于动画这个点是非常重要的,每当我遇到一个新的知识点,我就会和大家一起分享 animation-fill-mode :把物体动画地从一个地方移动到另一个地方,并让它停留在那里 ...
- Aspose.Cells.dll引用导入导出Excel
Aspose.Cells 导入导出EXCEL 文章出处:http://hi.baidu.com/leilongbing/item/c11467e1819e5417595dd8c1 修改样式 ...
- Django视图与网址传参
目的:采用/add?a=1&b=2 这样get/post方法进行 修改一下mysite/views.py文件 from django.shortcuts import renderfrom ...
- python3编码问题
继续收集python3编码问题相关资料 资料来源 鹏程的新浪博客(转载)http://blog.sina.com.cn/s/blog_6d7cf9e50102vo90.html 这篇鹏程老师写的关 ...
- poj 2796 Feel Good 单调栈区间问题
Feel Good 题意:给你一个非负整数数组,定义某个区间的参考值为:区间所有元素的和*区间最小元素.求该数组中的最大参考值以及对应的区间. 比如说有6个数3 1 6 4 5 2 最大参考值为6,4 ...
- iOS+JSPatch在线修改app功能-b
什么是热更新? 举个例子,你的app上架了,但是突然想添加个小功能,那么你有两种方法 第一种方法:在原生代码中修改源代码,然后提交到appStore,这个过程真是很漫长...虽然最近我提交的都是一两天 ...