Since updating to androidx.compose 1.2.0-alpha06 I'm unable to see any previews. I haven't found similar issues anywhere. Preview renderer crashes with the following message
java.lang.ClassNotFoundException: android.view.OnBackInvokedCallback
at com.android.tools.idea.rendering.classloading.loaders.DelegatingClassLoader.findClass(DelegatingClassLoader.kt:81)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at com.android.tools.idea.rendering.classloading.loaders.DelegatingClassLoader.loadClass(DelegatingClassLoader.kt:65)
at androidx.compose.ui.tooling.ComposeViewAdapter$FakeOnBackPressedDispatcherOwner$1.<init>(ComposeViewAdapter.kt:744)
at androidx.compose.ui.tooling.ComposeViewAdapter.<init>(ComposeViewAdapter.kt:743)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:352)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:189)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:149)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:301)
...
Similar issue has not been answered by anyone. Applying the workaround specified here did not work, although the case seems similar to mine, the error differs from mine, I guess that's the reason. I saw an issue that required to set the same compose-activity version as compose version, it did not help. My activity-ktx version is 1.6.0-alpha01.
I'm using Android Studio Bumblebee | 2021.1.1 Patch 3
CodePudding user response:
Try using Activity 1.5.0-beta01 as 1.6.0-alpha01 is only compatible with Android 13 Developer Preview 2 SDK as indicated here: https://developer.android.com/jetpack/androidx/releases/activity#1.6.0-alpha01