Search code examples
androidandroid-studioandroid-layout

Android Studio - layout preview isn't displaying (Security Manager is deprecated)


I opened an Android project after some time, and the layout preview isn't showing anything:

enter image description here

I'm using Android Studio Hedgehog | 2023.1.1 Patch 1

I also noticed that I have 3 errors in this file. All of them have the same title - The Security Manager is deprecated and will be removed in a future release.

  1. Exception raised during rendering: The Security Manager is deprecated and will be removed in a future release (Details)
  2. The Security Manager is deprecated and will be removed in a future release (Details)
  3. Error inflating the preview (Details)

When I clock Details, this shows up:

java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release
    at java.base/java.lang.System.setSecurityManager(System.java:429)
    at com.android.tools.rendering.security.RenderSecurityManager.setActive(RenderSecurityManager.java:196)
    at com.android.tools.rendering.RenderTask.createRenderSession(RenderTask.java:738)
    at com.android.tools.rendering.RenderTask.lambda$inflate$7(RenderTask.java:889)
    at com.android.tools.rendering.RenderExecutor$runAsyncActionWithTimeout$3.run(RenderExecutor.kt:202)
    at com.android.tools.rendering.RenderExecutor$PriorityRunnable.run(RenderExecutor.kt:316)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.base/java.lang.Thread.run(Thread.java:1583) 

enter image description here

The project itself is compiling without errors and changes in XML are applying correctly.

I tried opening a different file and creating a new project, but it didn't work.

I also tried File > Invalidate Caches (all 3 options) and Build > Clean Project.

Edit: Reinstalling Android Studio also doesn't help.


Solution

  • Turns out it's a bug and it's fixed in the newer versions of Android Studio. (in the new 'Iguana' Canary version it is not a problem anymore)