Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NullPointerException on render android layout

Any layout in my android project, generate a render exception:

Android Studio 1.2 Beta

java.lang.NullPointerException
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.isThemeAppCompat(RenderSessionImpl.java:1203)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.findStatusBar(RenderSessionImpl.java:1066)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.init(RenderSessionImpl.java:209)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:319)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:497)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:485)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:894)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:485)
    at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:590)
    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:351)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
like image 433
ridermansb Avatar asked Apr 15 '15 14:04

ridermansb


3 Answers

Switching the preview rendering target from 22 to 21 made the error go away for me on Android Studio 1.2 Stable.

enter image description here

like image 190
Daniel Zolnai Avatar answered Oct 14 '22 23:10

Daniel Zolnai


I got this error on the latest version of AS as of today, but for a different reason.

I renamed one of my app themes, then in all of the activity layout files that I had manually selected that theme for (in the theme drop down menu on the preview window), I was getting this error.

Once I realized this was the problem, I easily fixed it by just changing the theme to a valid/existing theme. Again I'm not talking about changing the defined theme for the activity, I'm talking about changing the PREVIEW theme.

like image 25
Siavash Avatar answered Oct 14 '22 22:10

Siavash


This is a bug in Android Studio Beta 1.2. After upgrading to 1.3, this does not occur

like image 20
ridermansb Avatar answered Oct 14 '22 23:10

ridermansb