Gradle build fails with 'Cannot resolve symbol' for imported Kotlin coroutines in Android 14 project
I'm writing unit tests and I'm having a hard time understanding I'm converting an old project and I've been banging my head against this for hours..... I'm facing an issue while trying to set up Kotlin coroutines in my Android application targeting Android 14. After successfully adding the necessary dependencies in my `build.gradle` file, I'm getting 'Cannot resolve symbol' errors for coroutines when I try to use them in my ViewModel. My dependencies look like this: ```groovy dependencies { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0" // Other dependencies } ``` I've synced my Gradle files multiple times, invalidated caches, and rebuilt the project, but the errors persist. Hereβs a snippet of my ViewModel code where Iβm trying to use coroutines: ```kotlin class MyViewModel : ViewModel() { private val _data = MutableLiveData<List<MyData>>() val data: LiveData<List<MyData>> get() = _data fun fetchData() { viewModelScope.launch { val result = myRepository.getData() // This function is supposed to return a Deferred<List<MyData>> _data.value = result.await() } } } ``` I double-checked that the `myRepository.getData()` function is implemented correctly and returns the expected type. I also confirmed that my Kotlin version is compatible by setting it in the `build.gradle`: ```groovy ext.kotlin_version = '1.6.10' ``` When I hover over the coroutine functions, I see a tooltip indicating that they are unresolved symbols. I've tried cleaning the project and even updating my Android Studio to the latest version as of October 2023, but nothing seems to resolve the issue. Has anyone else faced this problem, or does anyone know what might be causing this? Any help would be greatly appreciated! My development environment is macOS. Any ideas what could be causing this? I'd love to hear your thoughts on this. I'm working in a Windows 10 environment. What are your experiences with this? This is part of a larger mobile app I'm building. I appreciate any insights! My development environment is Windows 11. Am I missing something obvious?