Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.UnsupportedOperationException: Unsupported Service: accessibility android studio

I have ran into a problem with this UnsupportedOperationException. I have recently switched to android studio, so it is quite new for me. I wanted to add the recyclerview into my project, and do stuff with it, but the layout designer throws me this error:

java.lang.UnsupportedOperationException: Unsupported Service: accessibility
at com.android.layoutlib.bridge.android.BridgeContext.getSystemService(BridgeContext.java:465)
at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:290)
at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:266)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:379)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:99)
at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:172)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:401)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:329)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:333)
at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:674)
at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:663)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:663)
at com.android.tools.idea.rendering.RenderService.render(RenderService.java:790)
at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$6.run(AndroidDesignerEditorPanel.java:480)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)

What should be the problem, I don't honestly know. I've watched tutorials for implementing RecyclerView into the project, but this is what Android Studio gives me back after I use the official Google code.


EDIT: It seems it is resolved as the answer I accepted is correct, but I did not tried it on my own.

EDIT: As I accepted the current answer, it is somewhat relevant to my issue, but it's not a full solution. If anyone can or could provide some fix or workaround to this, I'll update the accepted answer as long as its providing such an information, or if the issue was solved by IntelliJ or whoever is the developer. Also thank you Dave for pointing out where it fails, at least we can write a ticket to devs :)

like image 996
Citrus Avatar asked Nov 07 '14 01:11

Citrus


3 Answers

This issue was finally fixed in the API Level 22 SDK Manager and RecyclerView support library. To quote this comment in the relevant Android issue (which was closed on March 11, 2015), you need to:

... update to the latest SDK platform for API 22 via the SDK Manager, and update to the latest recycler view by updating the Support repository via the SDK Manager, and in your build.gradle file to use the latest version (22.0.0)

In addition, at the top of the designer tool, you need to select API Android version 22. If you pick an earlier version, you will continue to see the error, even though you have the latest support library.

like image 173
cybersam Avatar answered Nov 11 '22 02:11

cybersam


BridgeContext.getSystemService() (as of 5.0.0 r1) will throw UnsupportedOperationException if the service requested isn't one of the following:

  • "layout_inflater"
  • "textservices"
  • "window"
  • "input_method"
  • "power"
  • "display"

In such cases, the Exception thrown will contain the name of the service that was requested.

It seems that IntelliJ's UI helpers haven't been updated, because BridgeContext shouldn't be asking for the "accessibility" service. As the commenters have suggested, stick to the XML layout, rather than the WYSIWYG.

like image 4
Dave Avatar answered Nov 11 '22 02:11

Dave


I found this error in latest 1.5.1 studio. In my case it is fixing by changing API level for previewing. enter image description here

like image 1
DmitryBorodin Avatar answered Nov 11 '22 03:11

DmitryBorodin