ClassCastException kotlin.coroutines.intrinsics.CoroutineSingletons cannot be cast to java.util.List
See original GitHub issueCurrent behavior
I am trying to access async storage from Java (i.e. Brownfield integration ->I implemented a widget in Java). I’ve followed the guide to read values
void readStorageValue(Context ctx, String key) {
AsyncStorageAccess asyncStorage = StorageModule.getStorageInstance(ctx);
BuildersKt.launch(GlobalScope.INSTANCE,
Dispatchers.getIO(),
CoroutineStart.DEFAULT,
(scope, continuation) -> {
List<String> keys = new ArrayList<>();
keys.add(key);
List<Entry> entries = (List<Entry>) asyncStorage.getValues(keys, (Continuation<? super List<? extends Entry>>) continuation);
doSomethingWithValues(entries);
return Unit.INSTANCE;
});
}
When readStorageValue
method gets called, my application crashes: ClassCastException kotlin.coroutines.intrinsics.CoroutineSingletons cannot be cast to java.util.List
Expected behavior
The application should not crash
Repro steps
Environment
- Platforms tested:
- Android
- iOS
- macOS
- Windows
- AsyncStorage version: 1.15.1
- Environment: System: OS: macOS 11.2.3 CPU: (8) x64 Intel® Core™ i7-4770HQ CPU @ 2.20GHz Memory: 66.86 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 15.11.0 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 7.6.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: Not Found IDEs: Android Studio: 4.1 AI-201.8743.12.41.7199119 Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: 15.0.2 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.1 => 17.0.1 react-native: 0.64.0 => 0.64.0 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Kotlin version 1.4.32
- Logs/Errors that may be relevant:
java.lang.ClassCastException: kotlin.coroutines.intrinsics.CoroutineSingletons cannot be cast to java.util.List
at com.vtoupet.smartmixin.utils.Storage.lambda$readStorageValue$0(Storage.java:43)
at com.vtoupet.smartmixin.utils.-$$Lambda$Storage$DXdrLrbhpt1sIvFEJaj9B7vmyWg.invoke
at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt$createCoroutineUnintercepted$$inlined$createCoroutineFromSuspendFunction$IntrinsicsKt__IntrinsicsJvmKt$4.invokeSuspend(IntrinsicsJvm.kt:205)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
kotlin.coroutines.intrinsics.CoroutineSingletons cannot be cast ...
Coroutines crash when upgrading to Kotlin 1.3.30 - kotlin.coroutines.intrinsics.CoroutineSingletons cannot be cast to java.lang.Boolean #1091.
Read more >kotlin.coroutines.intrinsics.CoroutineSingletons cannot be cast ...
CoroutineSingletons cannot be cast to retrofit2.Response ... ClassCastException: kotlin.coroutines.intrinsics. ... Caused by: java.lang.
Read more >"ClassCastException: class CoroutineSingletons cannot be ...
invokeSuspend@27: Error during job java.lang.ClassCastException: kotlin.coroutines.intrinsics.CoroutineSingletons cannot be cast to xxxx.api.json.
Read more >mockk-io/Lobby - Gitter
and Caused by: java.lang.ClassCastException: class kotlin.coroutines.intrinsics.CoroutineSingletons cannot be cast to class java.lang.Number.
Read more >org.json.jsonarray cannot be cast to java.util.list - You.com | The ...
java.lang.ClassCastException: CustomAdapter cannot be cast to android.widget. ... my application crashes: ClassCastException kotlin.coroutines.intrinsics.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Krizzu I’ve just submitted a PR #583 with the updated doc
Thanks, I’m going to close this issue then