1
proguardを無効にすると正常に動作しますが、proguardで使用するとjava.lang.IllegalStateException例外がスローされます:Scheduler.Workerスレッドで致命的例外がスローされます。retrofit2とrxjavaでproguardを使用するとエラーが発生する
これは私のコード
private fun getData(email : String) {
mSubscriptions!!.add(NetworkUtil.retrofit.getProfile(email)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe({ this.handleResponse(it) }, { this.handleError(it) }))
}
private fun handleResponse(user: List<User>) {
System.out.println(user.get(0).email)
}
private fun handleError(error: Throwable) {
if (error is HttpException) {
val gson = GsonBuilder().create()
try {
val errorBody = error.response().errorBody()!!.string()
val response = gson.fromJson<Response>(errorBody, Response::class.java)
showSnackBarMessage(response.message)
} catch (e: IOException) {
e.printStackTrace()
}
} else {
showSnackBarMessage("Network Error !")
}
}
であり、これは例外
FATAL EXCEPTION: main
Process: sega.com.myapplication, PID: 7784
java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread.
at rx.android.schedulers.LooperScheduler$ScheduledAction.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: rx.a.e: Error occurred when trying to propagate error to Observer.onError
at rx.d.a.a(Unknown Source)
at rx.d.a.onError(Unknown Source)
at rx.c.a.g$a.onError(Unknown Source)
at rx.c.a.f$a.a(Unknown Source)
at rx.c.a.f$a.a(Unknown Source)
at rx.android.schedulers.LooperScheduler$ScheduledAction.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: rx.a.a: 2 exceptions occurred.
at rx.d.a.a(Unknown Source)
at rx.d.a.onError(Unknown Source)
at rx.c.a.g$a.onError(Unknown Source)
at rx.c.a.f$a.a(Unknown Source)
at rx.c.a.f$a.a(Unknown Source)
at rx.android.schedulers.LooperScheduler$ScheduledAction.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: rx.a.a$a: Chain of Causes for CompositeException In Order Received =>
at android.util.Log.printlns(Log.java:415)
at com.android.internal.os.RuntimeInit.Clog_e(RuntimeInit.java:61)
at com.android.internal.os.RuntimeInit.-wrap0(RuntimeInit.java)
at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:86)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1063)
at rx.android.schedulers.LooperScheduler$ScheduledAction.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: retrofit2.adapter.rxjava.HttpException: HTTP 400 Bad Request
at retrofit2.adapter.rxjava.BodyOnSubscribe$BodySubscriber.onNext(Unknown Source)
at retrofit2.adapter.rxjava.BodyOnSubscribe$BodySubscriber.onNext(Unknown Source)
at retrofit2.adapter.rxjava.CallArbiter.deliverResponse(Unknown Source)
at retrofit2.adapter.rxjava.CallArbiter.emitResponse(Unknown Source)
at retrofit2.adapter.rxjava.CallExecuteOnSubscribe.call(Unknown Source)
at retrofit2.adapter.rxjava.CallExecuteOnSubscribe.call(Unknown Source)
at retrofit2.adapter.rxjava.BodyOnSubscribe.call(Unknown Source)
at retrofit2.adapter.rxjava.BodyOnSubscribe.call(Unknown Source)
at rx.d.a(Unknown Source)
at rx.c.a.g$a.a(Unknown Source)
at rx.c.c.a$b$1.a(Unknown Source)
at rx.c.c.f.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: b.a
at sega.com.myapplication.activity.LoginActivity.b(Unknown Source)
at sega.com.myapplication.activity.LoginActivity.a(Unknown Source)
at sega.com.myapplication.activity.LoginActivity.a(Unknown Source)
at sega.com.myapplication.activity.LoginActivity$e.a(Unknown Source)
at sega.com.myapplication.activity.LoginActivity$e.call(Unknown Source)
at rx.c.e.a.onError(Unknown Source)
at rx.d.a.a(Unknown Source)
at rx.d.a.onError(Unknown Source)
at rx.c.a.g$a.onError(Unknown Source)
at rx.c.a.f$a.a(Unknown Source)
at rx.c.a.f$a.a(Unknown Source)
at rx.android.schedulers.LooperScheduler$ScheduledAction.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
である私は、コンパイル使用してテストしていた、それはまだなく、 'com.artemzin.rxjava:1.3.0.0:ProGuardの-ルール' をあなたのproguard-rules.pro
ファイルにこれを追加すること
それでもエラー:(私はなぜ私はエラーが発生するのかわかりません:retrofit2.adapter.rxjava.HttpException:私がプロゴードを使用したときにHTTP 400の間違ったリクエスト –
あなたのモデルとリクエストをプロguardから除外しましたか? –
ああ男!わすれてた 。どうもありがとうございます 。あなたは私が4時間過ごすとき私の救助者ですが、なぜ私はこのエラーがあるのかわかりません:) –