3

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

The element is added with android:id="@+id/switch" which produces a compiler error: invalid symbol: 'switch'

I have to change the name to something else but "switch". Strange to see the system adding an invalid name but ok I could live with that.

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

Edit I add the 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 appears in the designer view instead of the activity once a switch is added.

Droidum
  • 440
  • 2
  • 9
  • Show the stack trace please. Maybe the API Level? – Héctor Aug 21 '14 at 07:19
  • stack trace added. Yes it is at API level. The whole thing happens in the designer only. I can run the app. Just the designer stops working if the switch is present. – Droidum Aug 21 '14 at 08:45
  • take a look: http://stackoverflow.com/questions/12757478/android-compoundbutton-switch-jumpdrawablestocurrentstate-null-crash – Héctor Aug 21 '14 at 08:52
  • ok I did but I am not using a selfmade element, this switch is from the basically installed tools. My API level is 17 so far above the suggested 14. I tried something below 14 but also no success.In contrast to the user in your link I can execute the app but I can't see my view in the designer. Any other ideas? – Droidum Aug 21 '14 at 11:20

0 Answers0