Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

偶发性报ClassCastException这个错误 #12

Closed
tanranran opened this issue Dec 29, 2020 · 4 comments
Closed

偶发性报ClassCastException这个错误 #12

tanranran opened this issue Dec 29, 2020 · 4 comments

Comments

@tanranran
Copy link

2020-12-29 16:51:22.082 18675-18675/com.aofa.baseplatform E/ARouter::: InstantRun support error, com.android.tools.fd.runtime.Paths
2020-12-29 16:51:24.147 18675-1835/com.aofa.baseplatform E/cutils-trace: Error opening trace file: No such file or directory (2)
2020-12-29 16:51:59.199 18675-18675/com.aofa.baseplatform E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.aofa.baseplatform, PID: 18675
java.lang.ClassCastException: androidx.lifecycle.LifecycleCoroutineScopeImpl cannot be cast to com.rxlife.coroutine.RxLifeScope
at androidx.lifecycle.RxLifeKt.getRxLifeScope(RxLife.kt:30)
at androidx.lifecycle.RxLifeKt.getRxLifeScope(RxLife.kt:24)
at com.aofa.baseplatform.ui.volunteer.VolunteerRegActivity.submit(VolunteerRegActivity.kt:83)
at com.aofa.baseplatform.ui.volunteer.VolunteerRegActivity$init$$inlined$apply$lambda$1.onClick(VolunteerRegActivity.kt:46)
at com.aofa.baseplatform.base.BaseActionBarWidget.onClick(BaseActionBarWidget.kt:282)
at android.view.View.performClick(View.java:7455)
at android.view.View.performClickInternal(View.java:7432)
at android.view.View.access$3600(View.java:810)
at android.view.View$PerformClick.run(View.java:28313)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7661)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:594)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

@liujingxing
Copy link
Owner

同一个类,rxLifeScope和lifecycleScope不要混用,二选一

@tanranran
Copy link
Author

@liujingxing 那能针对这种情况处理下吗?有的时候需要这样写

@liujingxing
Copy link
Owner

liujingxing commented Dec 30, 2020

rxLifeScope、lifecycleScope两者共用内存缓存,所以不能混用;如果想用,那就不要使用缓存,直接创建一个RxLifeScope对象即可,如下:

RxLifeScope().launch {  }

@tanranran
Copy link
Author

好的,谢谢作者,库很好用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants