Android intellij switch nullpointerexception

I am trying to put a switch widget in my activity in IntelliJ. When I do this, the designer crashes with a NullPointException exception inside android.widget.Switch.jumpDrawablesToCurrentState and a long stack trace.

Element added with android: id = "@ + id / switch", which throws a compiler error: invalid character: 'switch'

I need to change the name to another, but "switch." It is strange to see that the system adds an invalid name, but normal, I could live with it.

But the visual constructor is still useless when the switch is in the layout. The only thing I can find on Google is a bug tracker entry describing this. But there is no solution. What is going on there? Does anyone know a solution?

Edit I am adding a stack trace:

java.lang.NullPointerException at android.widget.Switch.jumpDrawablesToCurrentState(Switch.java:825) at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5158) at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5158) at android.widget.FrameLayout.jumpDrawablesToCurrentState(FrameLayout.java:189) at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5158) at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5158) at android.view.View.onAttachedToWindow(View.java:11560) at android.view.View.dispatchAttachedToWindow(View.java:11937) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2415) at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:42) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:393) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:332) at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:333) at org.jetbrains.android.uipreview.RenderService.createRenderSession(RenderService.java:127) at org.jetbrains.android.uipreview.RenderUtil.renderLayout(RenderUtil.java:154) at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$8.run(AndroidDesignerEditorPanel.java:346) 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.Alarm$Request$1.run(Alarm.java:289) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722)

This is displayed in the designer view instead of activity after adding the switch.

+3
source share

Source: https://habr.com/ru/post/1625945/


All Articles