To solve The following classes could not be found: androidx.compose.ui.tooling.preview.ComposeViewAdapter error follow below methods.
ERROR LOG
The following classes could not be found: - androidx.compose.ui.tooling.preview.ComposeViewAdapter (Fix Build Path, Edit XML, Create Class)
Contents
How to solve The following classes could not be found: androidx.compose.ui.tooling.preview.ComposeViewAdapter ?
The issue is with the version of Android Studio. You can solve this problem by simply downgrading to beta09 until AS ArticFox RC1 is released.
They split some packages in rc01, it appears to be a problem with the Android Studio version itself. You have two choices:
- Downgrade to beta09 until AS ArcticFox RC1 is released.
- Use the suggested workaround of using AS Arctic Fox Beta 5 while leaving all compose dependencies at 1.0.0-rc01 and downgrading only ui-tooling to 1.0.0-beta09.
Alternative to Fix The following classes could not be found: androidx.compose.ui.tooling.preview.ComposeViewAdapter
With Android Studio Bumblebee | 2021.1.1 Canary 6 and Android Gradle Plugin 7.1.0-alpha06, this is no longer required. Note that Canary 4 already fixed this problem, but it required an outdated version of AGP. This is also now resolved.
In addition to the answer provided above, here’s how to force the ui-tooling version in Gradle:
implementation("androidx.compose.ui:ui-tooling:$compose_version") {
version {
// TODO: Remove this when Android Studio has become compatible again
// Android Studio Bumblebee | 2021.1.1 Canary 3 is not compatible with module ui-tooling 1.0.0-rc01 or higher.
// The Run Configuration for Composable Previews that Android Studio makes expects a PreviewActivity class
// in the `androidx.compose.ui.tooling.preview` package, but it was moved in 1.0.0-rc01, and thus causes error:
// "androidx.compose.ui.tooling.preview.PreviewActivity is not an Activity subclass or alias".
// For more, see: https://stackoverflow.com/questions/68224361/jetpack-compose-cant-preview-after-updating-to-1-0-0-rc01
strictly("1.0.0-beta09")
}
}
Hope the above solution works.
Also read :
Node JS is not installed on win machine
Failed to connect to the remote extension host server (Error: Handler already set!)