Android studio渲染:空指针异常

时间:2015-04-02 03:48:47

标签: android android-studio

这是堆栈跟踪:

java.lang.NullPointerException
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.isThemeAppCompat(RenderSessionImpl.java:1201)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.findStatusBar(RenderSessionImpl.java:1063)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.init(RenderSessionImpl.java:206)
    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.RenderService$5.compute(RenderService.java:708)
    at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:697)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
    at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:697)
    at com.android.tools.idea.rendering.RenderService.render(RenderService.java:816)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:646)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:82)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:589)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:584)
    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:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

另一个活动使用相同的主题,并在渲染器中正常工作。如果有帮助,主题基于Theme.AppCompat.Light。我用完全相同的XML替换了文件,它工作正常,但编辑声称它无法找到它并开始在任何地方闪烁。重启后它有同样的问题。

我花了好几个小时试图解决这个问题并且一无所获。请帮帮我。

2 个答案:

答案 0 :(得分:28)

在Android Studio中更改xml查看器中的主题

答案 1 :(得分:0)

我认为这可能与您使用不受支持的主题有关。

例如,holo.light是Android Lollipop无法识别的主题。考虑用material.light替换它。

这对我来说至少是个问题。希望它有所帮助。